ngResource add Header not working


#1

I tried to add Authorization token in request header but not working for me
what the problem and how to fix issue ??

this when using POST :

function updateProfile(data){ return $q(function(resolve , inject){ var token = StorageService.getToken(); if(!token) console.log('no token') var resource = $resource(usersAPI.profile_update,null, { save:{ method:'POST', header:{ 'Authorization': 'Bearer ' + token } } }) var profile = resource.save(data,function(result){ console.log(result) },function(err){ console.log('error',err) }) console.log(profile) resolve(profile) }) }

and this when using GET :

function profile(){ return $q(function(resolve , reject){ var token = StorageService.getToken(); if(!token) console.log('no token') var resource = $resource(usersAPI.profile,null, { get:{ method:'GET', header:{ 'Authorization': 'Bearer ' + token } } }) var profile = resource.get(null,function(result){ console.log(result) },function(err){ console.log('error',err) }) resolve(profile) }) }

and thanks for helping :slightly_smiling: