How to make an NodeJS HTTP request to the RobotEvents API

I tried looking directly at the docs: How do I make a http request? | Node.js, but I followed it directly and it didn’t work.

Here is my current code:

const http = require('http')

const token = process.env.ROBOTEVENTS_TOKEN
const host = '', path = '/api/v2/events?sku%5B%5D=RE-VRC-21-5414&myEvents=false'

var options = {
  host: host,
  path: path,
  headers: {
    Authorization: `Bearer: ${token}`,
    accept: 'application/json'

callback = function(response) {
  var str = ''

  response.on('data', function (chunk) {
    str += chunk;

  response.on('end', function () {

var req = http.request(options, callback);

You would likely want to make use of the fetch API, as this makes consuming JSON significantly easier in Node.js.

Alternatively, consider using the robotevents module I wrote a little while back, which should hopefully abstract over a lot of the API


Are you talking about this Fetch API:
Also, how would you include headers in the Fetch API request?