DenoDDeno
Powered by
wedmaniacW
Deno•16mo ago•
15 replies
wedmaniac

Parsing a fetch response resulting number turning into NaN

Hi there! I'm making a website where I try to gameify the experience. However now im stuck with a problem! So I fetch energy from my supabase table. So far so good. but when I parse the response one field ("balance") gets turned into NaN!
const fetchEnergy = async () => {
    const response = await fetch("/api/get/energy", { method: "GET" });
    const rawResponse = await response.text();
    console.log("Raw API response:", rawResponse);

    const data = JSON.parse(rawResponse);
    console.log("Parsed API response:", data);
    ....
const fetchEnergy = async () => {
    const response = await fetch("/api/get/energy", { method: "GET" });
    const rawResponse = await response.text();
    console.log("Raw API response:", rawResponse);

    const data = JSON.parse(rawResponse);
    console.log("Parsed API response:", data);
    ....

I have no idea how to resolve the issue here!
Thanks for the help in advance ❤️
image.png
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

cannot set property on fetch response
ChilliSniffCChilliSniff / help
3y ago
How to feed a ReadableStream / async Generator into a Response object?
spirobelSspirobel / help
3y ago
Parsing Apache mime.types into dictionary Record<string, string>
BairdyBBairdy / help
3y ago