Function searchByName

  • Type Parameters

    Parameters

    • name: string

      The name to search for

    • Optional options: {
          exact?: boolean;
          fields?: F[];
      }

      The options

      • Optional exact?: boolean

        Whether to search for the exact name

      • Optional fields?: F[]

        The fields to keep in the response

    Returns Promise<Nullable<Pick<Country, F>[]>>

    The matching countries

    Description

    Search among the countries by their name

    Example

    const country = await searchByName('United States');
    const country = await searchByName('United States', { exact: true });
    const country = await searchByName('United States', { fields: ['name', 'capital'] });