wedmaniacW
Deno14mo 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);
    ....

I have no idea how to resolve the issue here!
Thanks for the help in advance ❤️
image.png
Was this page helpful?