#How to send back json
1 messages · Page 1 of 1 (latest)
1 messages · Page 1 of 1 (latest)
I would like to send back json in the start of the file.
Is something like this possible? Example:
---
return {key: "value"}
---
Or do I need to stringify the object and put it in body? Like this:
---
const myObj = {key: "value"}
let responseText: String = JSON.stringify(myObj)
---
{responseText}
I'd understood correctly, you want to display json in your page ?
"return json" from a page?
I mean I want to sendback json
You could do that with api routes https://docs.astro.build/en/core-concepts/endpoints/
k