Require is not defined


#1

I’m using this

// Example requires the use of the 'request' library // https://www.npmjs.com/package/request

var request = require("request");
var token = 'API_TOKEN'

var options = {
  method: 'GET',
  url: 'https://api.ionic.io/auth/test',
  headers: {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
  }
};

request(options, function(err, response, body) {
   if (err) throw new Error(err);
   console.log(body);
});

From the ionic api site: http://docs.ionic.io/api/http.html

But I get this error

ReferenceError: require is not defined ionic.bundle.js:26794

in the console. I’m running it on my phone and I’m using remote chrome debug for the console. I tried using requireJS but that did not much because that needs to get required too, so I dont get the point of that plugin.

why is this happening??