【发布时间】:2019-08-14 03:14:31
【问题描述】:
当我将数据发送到 REST API 时,它会以单个数组的形式发送,例如
Array ([
{
"username":"karthik@w3cert_in",
"password":"05550",
"grant_type":"password",
"client_id":"Outfit1548925669",
"client_secret":"a10620c85033ab02b582d17716cda245"
}
]=> )
但我需要发送这样的数据
Array
(
[username] => karthik@w3cert.in
[password] => 05550
[grant_type] => password
[client_id] => Outfit1548925669
[client_secret] => a10620c85033ab02b582d17716cda245
)
这是我正在使用的代码:
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});
let postcredentials = {
'username' : credentials.username,
'password' : credentials.password,
'grant_type' : credentials.grant_type,
'client_id' : credentials.client_id,
'client_secret' : credentials.client_secret,
};
console.log('iii'+(postcredentials) );
this.http.post(apiUrl, postcredentials, options)
.subscribe(res => {
console.log(JSON.parse(JSON.stringify(res)));
}, (err) => {
console.log(apiUrl);
});
}
【问题讨论】:
标签: arrays laravel typescript ionic-framework ionic3