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

Convert category dropdown to pull data from API #262

Open
MiguelLopez6 opened this issue Jul 18, 2020 · 2 comments
Open

Convert category dropdown to pull data from API #262

MiguelLopez6 opened this issue Jul 18, 2020 · 2 comments
Labels
enhancement New feature or request Hackathon Issues we think could be tackled during a Hackathon Up for grabs Anyone can offer to take on these tickets
Milestone

Comments

@MiguelLopez6
Copy link
Contributor

What we need to code

Create a REST API call to get the categories from https://nccovid.vizioz.com/api/v1/resource/settings

HTTP GET https://nccovid.vizioz.com/api/v1/resource/settings

Use the data returned to populate the category selection dropdown.

The data returned is in JSON format, and returns an object containing both a category list (including subcategories) and a regions list. Only the categories are to be used now.

Additional context

The documentation for the API can be found at https://github.com/Vizioz/CovidSupport/blob/master/documentation.md

@readingdancer readingdancer added Hackathon Issues we think could be tackled during a Hackathon Up for grabs Anyone can offer to take on these tickets enhancement New feature or request labels Jul 18, 2020
@readingdancer readingdancer added this to the Version 1.3 milestone Jul 18, 2020
@readingdancer
Copy link
Contributor

Please add the API URL to the /themes/theme.config.js file so that it is configurable per site.

@jasonajones73
Copy link
Collaborator

jasonajones73 commented Jul 24, 2020

@readingdancer & @MiguelLopez6, I started taking a look at this and I keep running into the same error as I'm testing. I have the API call working fine in a stand-alone script but just not sure if it is a server issue or something I'm doing that is hanging things up.

I'm trying to use axios to make the call on component create or mount but keep getting this error message:

Access to XMLHttpRequest at 'https://nccovid.vizioz.com/api/v1/resource/settings' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

GET https://nccovid.vizioz.com/api/v1/resource/settings net::ERR_FAILED

Here is my axios API call for your reference:

const apiClient = axios.create({
      baseURL: 'https://nccovid.vizioz.com/api/v1/',
      withCredentials: false,
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json'
      }
    })
    apiClient
      .get('resource/settings')
      .then((response) => (this.categories = response.data.categories))

Do you know if this is something with the server or an issue with my code? I apologize if this is something basic or obvious. I am pretty new to this with JavaScript. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Hackathon Issues we think could be tackled during a Hackathon Up for grabs Anyone can offer to take on these tickets
Projects
None yet
Development

No branches or pull requests

3 participants