I have a code that takes the JSON of a webpage (from a link) and prints it into the console with a promise, using node-fetch (npm node-fetch) and .then
I need to get the content of this specific webpage to work with that content for a project I have, but I cannot see any solution on how to really use it
I have this code:
fetch('https://api.faceit.com/core/v1/nicknames/'+req.query.nickname)
.then(res => res.text())
.then(body => console.log("json -> "+body))
req.query.nickname is a text variable taken from a form that will serve for the link I use to print the JSON
now, when I get to .then(body => console.log("json -> "+body)) it correctly prints me the JSON but I have no clue on how to use the body that I print
Now, after all this, I have 2 questions
- how can I used the "body" variable to work with the data I get out of that link?
- is there any different way (better or not) to get the content from a page, stored into a variable or an Object, that I can work with?
thanks for everyone for the help in advance. If you need an example of the JSON I need to work with, you can use this https://api.faceit.com/core/v1/nicknames/noxter