Category Archives: NodeJs

Node.js Set cookies on HTTPS Requests

If you are not sure how to set up cookies with Node.js and HTTPS / HTTP requests to a specific page then this will definitely help you understand how you can do it.

I’ve confronted with this confusion too since I did not find much on the documentation of specific Node.js libraries that provide requests.

Lets say you have a Node.js https.get and you want to send a request to a specific page but you need a cookie in order to access that page for some reason. Here is how it should look :

 

If you want to send multiple cookies in one request then it would look something like this

 

Hope this helps you ! Have a nice day

Get Minecraft Server Status with NodeJs Request

With this simple snippet and quick snipped you can get the status of your or other’s minecraft server just by entering 1 command line with NodeJs.

Keep in mind that you should have some basic understanding of NodeJs and a local installation where you can test out the code below.

 

You should also have installed the NodeJs Request library. The code above is basically sending a GET request to mcapi.us to get the current status of the minecraft server.

Run it like this:

node app.js SERVER_IP SERVER_PORT