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.
Got is another good one.
And so is ky
.
Pretty sure you can also find the cURL bindings on NPM too!
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.
Ohhh,i’m such a coding newb
It’s okay, everyone starts as a newbie and a noob, so feel free to ask out!
thanks,but i feel dumb not knowing this when a 14 y/o does,and i’m 16
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);
}
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
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.
Thank you very much! this worked perfectly
i’m glad your website is working now!hope you start making more great projects one day