Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue getting postcode_by_state #3376

Closed
9 of 10 tasks
tylermaran opened this issue Jan 19, 2025 · 2 comments
Closed
9 of 10 tasks

Issue getting postcode_by_state #3376

tylermaran opened this issue Jan 19, 2025 · 2 comments
Labels
m: location Something is referring to the location module p: 1-normal Nothing urgent question Further information is requested
Milestone

Comments

@tylermaran
Copy link

Pre-Checks

Describe the bug

Trying to generate a state and then use the result to get a zipCode.

const state = faker.location.state({ abbreviated: true });
const zipCode = faker.location.zipCode({ state: state });

Getting the following error:

Uncaught u: The locale data for 'location.postcode_by_state' are missing in this locale.
  Please contribute the missing data to the project or use a locale/Faker instance that has these data.

I've verified that the response from state is a correct 2 character state code (i.e. PA, GA, CT).

Also tried passing a string to no avail.

const zipCode = faker.location.zipCode({ state: "GA" });

The error is getting thrown from line 83 here:

this.faker.definitions.location.postcode_by_state[state];

Minimal reproduction code

No response

Additional Context

No response

Environment Info

System:
    OS: macOS 13.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 72.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 131.0.6778.266
    Safari: 16.6

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

@tylermaran tylermaran added c: bug Something isn't working s: pending triage Pending Triage labels Jan 19, 2025
@ST-DDT
Copy link
Member

ST-DDT commented Jan 19, 2025

I assume you want to generate the postcodes for en_US?
If yes, please use fakerEN_US.location.zipCode({state:'GA'})

or add the missing data from the en_US locale:

faker.rawDefinitions.location.postcode_by_state = en_US.location.postcode_by_state;

Does this solve your issue?

@ST-DDT ST-DDT added question Further information is requested p: 1-normal Nothing urgent m: location Something is referring to the location module and removed c: bug Something isn't working s: pending triage Pending Triage labels Jan 19, 2025
@ST-DDT ST-DDT added this to the vAnytime milestone Jan 19, 2025
@tylermaran
Copy link
Author

Resolved. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
m: location Something is referring to the location module p: 1-normal Nothing urgent question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants