Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

Require is not defined

$
0
0

@thomas96 wrote:

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??

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>