javascript - gulp js gave the error when i changed my js files..| throw er -
i build new js file in ng directory user.svc.js , contents of file are
angular.module('app') .service('usersvc',function($http) { var svc = this; svc.getuser = function () { return $http.get('http://localhost:3000/api/users',{ headers:{'x-auth : this.token'} }) } svc.login = function(username,password){ return $http.post('http://localhost:3000/api/sessions',{ username:username,password:password }).then(function(val){ svc.token = val.data; return svc.getuser(); }) } })
the error getting is:
c:\users\setcodestofire\documents\modernweb\app>gulp js
[00:57:06] using gulpfile ~\documents\modernweb\app\gulpfile.js
[00:57:06] starting 'js'...
[00:57:06] finished 'js' after 79 msevents.js:160
throw er; // unhandled 'error' event
^
error: app.js: error: couldn't process source due parse error
unexpected token (54:2)
can tell me problem.do has $http?
change header values object format instead of string value
change
headers:{'x-auth : this.token'}
to
headers: { 'x-auth' : 'this.token' }
Comments
Post a Comment