在javascript中使用正文和标题发布请求 [英] Post request with body and headers in javascript
本文介绍了在javascript中使用正文和标题发布请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我的帖子请求
hi i have post request
function GetTokenfromGrap(resource, obj, failureCallback) {
debugger;
var deffered = $q.defer();
resource = '/xxxxx.com/oauth2/token'
var url = baseUrl + resource;
var configurations = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
}
$http.post(url, obj, configurations).then(deffered.resolve).catch(function (data) {
handleCatch(data);
if (typeof failureCallback === 'function') failureCallback(data);
});
return deffered.promise;
}
i想要为此添加身体请求,我该怎么办
我尝试过:
i googled它但我没有得到任何解决方案
i want to add body to this request , how can i do this
What I have tried:
i googled it but i didn't get any solution
推荐答案
q.defer();
resource ='/ xxxxxx.com/oauth2/token'
var url = baseUrl + resource;
var configurations = {
headers:{'Content-Type':'application / x-www-form-urlencoded'},
}
q.defer(); resource = '/xxxxx.com/oauth2/token' var url = baseUrl + resource; var configurations = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }
http.post(url,obj,configurations).then(deffered.resolve).catch(function(data){
handleCatch(data);
if(typeof failureCallback ===' function')failureCallback(data);
});
return deffered.promise;
}
http.post(url, obj, configurations).then(deffered.resolve).catch(function (data) { handleCatch(data); if (typeof failureCallback === 'function') failureCallback(data); }); return deffered.promise; }
i想要为此添加身体请求,我该怎么办
我尝试过:
i搜索它但我没有得到任何解决方案
i want to add body to this request , how can i do this
What I have tried:
i googled it but i didn't get any solution
obj是正文。
这篇关于在javascript中使用正文和标题发布请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文