Save response from API response
# 🤝help
f
What line of code would I use to save the response I got from an API call and then convert it into text. Here is the picture of my code:

https://cdn.discordapp.com/attachments/1141035599319547954/1141035599617347684/image.png

h
fetch('https://api.example.com/data') .then(response => response.json()) .then(jsonResponse => { const responseText = JSON.stringify(jsonResponse); console.log(responseText); // or do something else with the response text }) .catch(error => { console.error('Error:', error); }); https://api.example.com/data would be your website url. For saving, you need to decide where to store. If you would store data to databases like sql, mongodb, you need to create backend api endpoints and call that api endpoint to save data.
f
I just want to save it in a variable
h
great, then you can use fetch or axios.
and check using console.log()
f
Thank you!
h
Let's help each other!
f
I am a newbie I am not I can help you much, but lets try
h
no worries.
f
What's your problem?
h
I don't have problems, I joined here to get jobs.
As I am an experienced developer
f
Alright great good luck with that!
Didn't work
9 Views