【发布时间】:2019-08-14 05:31:33
【问题描述】:
当我尝试使用 ionic 将关联数组中的数据发布到 rest api 时。 服务器端只接收空数据。 这种方法是否正确或建议任何其他方法
public login(credentials) {
let apiUrl = this.urlService.apiUrl + 'oauth/access_token';
let headers = new Headers({'Content-Type' : 'application/x-www-form-urlencoded'});
let options = new RequestOptions({
headers: headers});
var postcredn=new Array();
postcredn['username'] = "karthik@abcde.in";
postcredn['password'] = "05550";
postcredn['grant_type'] = "password";
postcredn['client_id'] = "Outfit1548669";
postcredn['client_secret'] = "a10620c85033abd17716cda245";
console.log('iii'+postcredn['username'] );
return new Promise((resolve, reject) => {
this.http.post(apiUrl, postcredn, options)
.subscribe(res => {
resolve(JSON.parse(JSON.stringify(res)));
console.log('json'+ JSON.stringify(postcredn));
}, (err) => {
reject(err);
console.log(apiUrl);
});
});
}
} console.log(apiUrl);
});
});
}
}
提前致谢
【问题讨论】:
标签: laravel authentication ionic-framework oauth ionic3