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

Incorrect region_id datatype in json/subregions.json #956

Open
gschaer opened this issue Feb 12, 2025 · 1 comment · May be fixed by #957
Open

Incorrect region_id datatype in json/subregions.json #956

gschaer opened this issue Feb 12, 2025 · 1 comment · May be fixed by #957
Labels
bug Something isn't working

Comments

@gschaer
Copy link

gschaer commented Feb 12, 2025

In the json/subregions.json file, the "region_id" is stored as a string instead of an int.
Example:

This breaks the demo website as the filterSubregions function tries to search for an int in the key (using parseInt)

const subregions = await getFromIndex('subregions', 'region_id', parseInt(regionId));

The behavior we see on the demo website is that when selecting a region, no subregions are returned.

Copy link

dosubot bot commented Feb 12, 2025

Hey @gschaer! I'm here to help you with any bugs, questions, and becoming a contributor. Let's tackle this issue together while we wait for a human maintainer.

To resolve the issue with the region_id being stored as a string in the json/subregions.json file, you should adjust the filterSubregions function in app.js to handle string comparisons instead of converting regionId to an integer. Here's how you can modify the function:

async function filterSubregions(regionId) {
  console.log(typeof regionId);
  const subregions = await getFromIndex('subregions', 'region_id', regionId); // Use regionId as a string
  console.log(subregions);
  renderSubregions(subregions);
  document.querySelector('.countries-tb').innerHTML = '';
  document.querySelector('.states-tb').innerHTML = '';
  document.querySelector('.cities-tb').innerHTML = '';
}

By using regionId as a string, you ensure that the data types match, allowing the filterSubregions function to correctly retrieve and display the subregions on the demo website [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other | Bug Report

@dosubot dosubot bot added the bug Something isn't working label Feb 12, 2025
@gschaer gschaer linked a pull request Feb 12, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant