Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

ngResource add Header not working

$
0
0

@nuruddinba691 wrote:

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:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



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