Function searchByCode

  • Type Parameters

    Parameters

    • code: string | string[]

      The code(s) to search for

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

      The options

      • 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 code (cc2, ccn3, cca3, cioc)

    Example

    const countries = await searchByCode('usa');
    const countries = await searchByCode(['usa', 'gb'])
    const countries = await searchByCode('usa', { fields: ['name', 'capital'] });