我试图获得响应的OAuth服务正在工作,但是我的代码中有错误,没有发出请求。
$http.post(myURL, 'grant_type=password&username=' + userName + '&password=' + passWord,
headers: { 'Content-Type: application/x-www-form-urlencoded', 'Authorization Basic ' + btoa(secretWord) }).
success(function (response) {
console.log(response);
}).
error(function (response) {
console.log(response);
});发布于 2015-05-31 07:39:43
您有语法错误,因此JS不会发出HTTP请求,请尝试如下:
$http.post(myURL, 'grant_type=password&username=' + userName + '&password=' + passWord,
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + btoa(secretWord) } }).
success(function (response) {
console.log(response.data);
}).
error(function (response) {
console.log(response.status);
});https://stackoverflow.com/questions/30554898
复制相似问题