Glitch giving me HTML instead of my JSON data

I’m running a small testing thing on glitch, using Express it will send me a JSON response along the lines of:


And i’m getting HTML (The loading screen on my active project)
How the heck do I fix this! My local JS errors on the json.parse(response) because of the stupid HTML!
(It’s using a POST request, not a GET request and my project is online and works for me when I use my browser to GET it.)

1 Like

Welcome thetayloredman to the community.
You should contact Glitch Support by emailing them at here or submit a ticket here.

@SplitXPlayZ 日本語が話せいますか?

@thetayloredman I can’t really tell, but I suspect you’re using res.render (serves html/templater file) instead of res.send. Can you share a link to your Glitch project and any errors that show up in the console/DevTools?

1 Like

It might be a server error, what is the response code? What do you mean by the HTML being the loading screen?

Nope, I’m sending my JSON via res.json({some:'object'}). The project link is here:

The main problem I’m having is the Glitch Waking Up screen sending HTML, which JSON.parse does not like.

@mishavee The built-in glitch wake up screen. Response is 200 OK. I got it to work via curl sooooooo yeah idk anymore

Please help :frowning:

Unfortunately you might need to add code to detect the glitch loading screen and retry requests, you can use the Content-Type header to check for white type of data is sent

1 Like

But the project is online and I can GET it from my browser and curl so I can’t see why this would be so

In your javascript, try setting a request header content-type or change the method to POST, its an old workaround, idk if it still works though

1 Like

If you can set headers, set this as the header for that page:

Content-Type: application/json

Response and request already have it

Where are you serving the “local JS” from?

@glitch_support this used to work Opt out of "Waking up" interstitial - #4 by wh0. What has happened?

Anyway, it was said a long time ago that setting Content-Type on the request would help. I never tried this, because it seemed too weird. Maybe give that a shot :woman_shrugging:

Already have Content-Type: application/json set on request