Where you can do a post/get with the dynamic data on each line item
Yeah, I can do that as a last resort I just want to be able to do it inside the table component
Cause this DOES work. If I alert() the output, I do see the relevant data in my browser. I just can’t get the code component to output it.
So are you abke to drag the data fetch component into a table row?
Otherwise another hacky solution would be to create a state variable object/array
And then in that code
Store the output in the appropriate array item of your state variable
Then reference rhat in the table. Very hacky. Bur if you can pull the data fetch component into the table thats probably best
Or also try in that code to
Place a return statement before your fetch request
And remove the variable declaration
What would I do to this code then?
await fetch('<https://api.postcodes.io/postcodes/placeholder>')
.then(response => response.json())
.then(data => {
primaryCareTrust = data.result.primary_care_trust;
});
Replace await with return
OR;
let primaryCareTrust;
await fetch('<https://api.postcodes.io/postcodes/placeholder>')
https://api.postcodes.io/postcodes/placeholder’)
`.then(response => response.json())
.then(data => {
primaryCareTrust = data.result.primary_care_trust;
});
return primaryCareTrust;`
replacing await with return does this:
Ok yes sorry in that case use the second code snippet I sent
Seem to get the same result
however…
When I hover over that it TELLS me the output. How can I get that data outputted though?
Did you place return in front primaryCareTrust there at the end?
And did you declare it asvariable at the top? The snippet is cropped so can’t tell