'Firebase function using axios.get, receives error "Request has invalid method. GET"

First time trying out Firebase Functions and I cannot get this to work. I've tested in Postman with no problems. Is it something obvious? I also tried with Axios as well and no luck.

The error in the logs: Request has invalid method. GET

The error at the endpoint:

{"error":{"message":"Bad Request","status":"INVALID_ARGUMENT"}}

This is my attempt in the functions index.js

const functions = require("firebase-functions");
const https = require('follow-redirects').https;
const fs = require('fs');

const options = {
    'method': 'GET',
    'hostname': 'industrial.api.ubidots.com',
    'path': '/api/v2.0/devices/',
    'headers': {
      'X-Auth-Token': '***********'
    },
    'maxRedirects': 20
  };
  
  exports.getDevices = functions.https.onCall((data, context) => {
    var req = https.request(options, function (res) {
        var chunks = [];
    
        res.on("data", function (chunk) {
        chunks.push(chunk);
        });
    
        res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
        });
    
        res.on("error", function (error) {
        console.error(error);
        });
    });
    
    req.end();
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source