Ask coding questions

← Back to all posts
Request JSON data from API endpoint to each page requested
andersonbosa (0)

I'm doing the following test:

I want to extract from each page of this API:
https://frontend-intern-challenge-api.iurykrieger.now.sh/products?page=1
The information to create 8 items for "products? Page = 1"

Commentshotnewtop
ash15khng (234)

What language are you using?

andersonbosa (0)

@ash15khng Hi! i'm using python. I'm looking for how to use Flask and BS4 to request one time from the API, parse the JSON and create 8 products items per each page of my flask website (example: /products/page/1).

:(((((
I can imagine what, but not how.

malvoliothegood (107)

What programming language are you using? Its quite easy to do using the HTML/CSS/JavaScript combo.

andersonbosa (0)

@malvoliothegood wtf!!! can u help me so?? I'm using Flask (python) because I'm not familiar with javascript :p

(and also, it's a university job)

malvoliothegood (107)

@andersonbosa
Post a link to your repl so I can see what you have done so far.

malvoliothegood (107)

@andersonbosa
I suggest you use another online IDE such as PythonAnywhere
repl.it is not set up to use Flask (however it can accommodate DJango)

andersonbosa (0)

@malvoliothegood nice, but i trying to do in js now :< i need learn more js

malvoliothegood (107)

@andersonbosa
If you wanted to generate separate pages for each product then I suggest you use a frontend framework like React (tutorial: https://www.taniarascia.com/using-react-router-spa/). React is cool, but there is a reasonably steep learning curve and you need to know JavaScript quite well for a start.

If you want to just have one page with all the products listed on it you could use plain HTML and JavaScript (add in some CSS to style the page). Have a look at this repl: https://repl.it/@malvoliothegood/Products

Happy coding :)