Make an http request to glitch.me project returns the "waking up" page every time

I’m trying to make a get request to my glitch project, but it returns the “waking up” page, even after the projected has been awoken in a browser.
https.request(“websitewe.glitch.me”, res => {
var str = ‘’
res.on(‘data’, function (chunk) {
str += chunk;
});
res.on(‘end’, function () {
console.log(str)
})
}).end()

what’s that page?

Rather than using the native https module, I suggest using something like Axios or node-fetch. That way I don’t think you’d face the same trouble.

2 Likes

Got is another good one.

1 Like

And so is ky. :slightly_smiling_face:

Pretty sure you can also find the cURL bindings on NPM too!

1 Like

All non-static pages go to sleep after 5 minutes of inactivity, and when they wake up, you’ll see a page similar to this:

While the project “wakes up”, you can draw on the webpage.

2 Likes

Ohhh,i’m such a coding newb :confused:

It’s okay, everyone starts as a newbie and a noob, so feel free to ask out! :slightly_smiling_face:

4 Likes

thanks,but i feel dumb not knowing this when a 14 y/o does,and i’m 16

2 Likes

Thanks for the help! I was wondering if you could set me on the right path to using the node-fetch module though. I tried to use their example code but its not returning

    async() => {
        const response = await fetch(`websitewe.glitch.me`);
        const json = await response.json();
        console.log(json);
    }
1 Like

I’m not the node expert, but this looks like the code example for JSON APIs. Is there an example for HTML pages?

i know of an html editor from another forums

good point. i’ll try it with normal text, but my website does return json

um if you can use this somehow,here’s the link to the editor

Snap! 6.3.5 Build Your Own Blocks

It looks like its returning HTML.

well… ya. it returns html with a normal url, but the actual url i’m putting in is way longer. regardless, i tried it with text (and just on the base page like you just did with the cURL) and it’s still not returning anything

Could you try this:

fetch('your website here')
    .then(res => res.text())
    .then(body => console.log(body));

This looks like the example that you want.

1 Like

Thank you very much! this worked perfectly

3 Likes

i’m glad your website is working now!hope you start making more great projects one day

1 Like