Kaleksy
Kaleksy2mo ago

Accessing API data

Hi community! I would like to ask question related to handling API data. How to target and use data coming from API call? const url = https://rinki-api.vercel.app/api/points?municipality=Enontekiö; const data = await fetch(url, { parse: true }); const firstWhatever = data[0]; const type = typeof firstWhatever; return { trace: [ { type: "text", payload: { message: Testing API for "${data}" and "${firstWhatever}" } } ] }; Result is: "Testing API for "[object Object]" and "undefined""
1 Reply
W. Williams (SFT)
Is this in a function? Parse: true does nothing. do:
const response = await fetch(url);
const data = await response.json;
const response = await fetch(url);
const data = await response.json;

Did you find this page helpful?