cordova-plugin-advanced-http: JSON request with array data is not working on Android (JSON error)
Hello, I am getting JSON error when I would like to send array data in post request
this.http.setDataSerializer("json");
this.http
.post(
"https://localhost/api/create",
[{ test: 1 }, { test: 2 }],
{
"Accept": "application/json",
"Content-Type": "application/json"
}
)
.then((response) => {
console.log('response', response);
})
.catch((error) => {
console.log('error', error);
})
;
I try somethink like below but still same error JSON error
this.http.setDataSerializer("urlencoded");
this.http
.post(
"https://localhost/api/create",
JSON.stringify([{ test: 1 }, { test: 2 }]),
{
"Accept": "application/json",
"Content-Type": "application/json"
}
)
.then((response) => {
console.log('response', response);
})
.catch((error) => {
console.log('error', error);
})
;
Plagin
cordova-plugin-advanced-http 1.5.10 "Advanced HTTP plugin"
How can I send json request with array data?
Thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (4 by maintainers)
@silkimen Yes I just tested in iOS 10.3
with this code
and resulted in successful request