Set up a development environment with Node.js

For the quick start guide tutorial, we are using Node.js to run a server-side application that will make requests to and from the Go1 API. This mini-tutorial will walk you through how to install and run Node.js on your system.

If this concept is new to you and you would like to learn more, head over to our Marketplace to learn more about Node.js and Javascript.

1. Install Node.js from their website

2. Open Visual Studio Code and create a new file. Save it as 'server.js' in any location on your system.

3. In the 'server.js' file, we are going to set up an HTTP request and application that will run on localhost port 3006. To do so insert the following code block into your 'server.js' file.

/* Load the HTTP library */
  var http = require("http");

  /* Create an HTTP server to handle responses */

  http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
  }).listen(3006);

4. To run this file, open your terminal and using command prompts navigate to the 'server.js' file.

(You can run a terminal in Visual Studio Code by going to the task bar -> click on 'Terminal -> 'New terminal'.

5. Once you have navigated to the 'server.js' file, run the code by entering the following command in terminal

node server.js

6. Open a browser and go to the following URL 'localhost:3006'

You should see your server application running, saying 'Hello World'.

Congratulations! You have created a server-side application with Node.js! Now let’s stop running this application on the server by canceling it with CMD+C (Mac) CTRL+C (PC) in the terminal.