1

I am trying to use axios to make Http calls in my angular 2.0 project. The console is giving a Uncaught ReferenceError: require is not defined error Is this because require is a node function and not available in angular ?

I installed axios using npm install axios. Is this not the right way to use axios in angular ?

Thanks !

Clarkie
  • 7,490
  • 9
  • 39
  • 53
user636525
  • 3,180
  • 9
  • 38
  • 51
  • 1
    You can use Angular's [Http](https://angular.io/docs/ts/latest/api/http/Http-class.html) class instead of axios. Here's a [SO example](http://stackoverflow.com/questions/34389340/angular2-code-organisation-of-web-service-http-requests). – Mark Rajcok Dec 23 '15 at 04:33
  • Thanks ! I ended up doing just that. – user636525 Dec 24 '15 at 19:14
  • Here's another [SO example](http://stackoverflow.com/a/34450948/215945). This one uses the async pipe in the view to implicitly subscribe on the observable object returned from Http. – Mark Rajcok Dec 25 '15 at 17:51

0 Answers0