createResource does not working with json()

Why does text() work but json() does not:
let [schema1] = createResource(async _ => await (await fetch(`https://api.localhost/`)).json());
let [schema2] = createResource(async _ => await (await fetch(`https://api.localhost/`)).text())
let [schema1] = createResource(async _ => await (await fetch(`https://api.localhost/`)).json());
let [schema2] = createResource(async _ => await (await fetch(`https://api.localhost/`)).text())
I am sure the content I get back is valid JSON and changing the content type has no effect. I can't think of a reason why this difference in behaviour?
2 Replies
JCM
JCM2y ago
Indeed, I don't see a reason for a difference of behavior. Both options should work. When I try it, both work: https://playground.solidjs.com/anonymous/1ae43cce-3875-41b5-9eb7-cd4eda05ad07 It obviously isn't the same for you. It would be helpful to describe more precisely what doesn't work.
Alex Lohr
Alex Lohr2y ago
Can you check the request in the network tab?
Want results from more Discord servers?
Add your server