//This is our code for pass the data in API tell me anyone how to fix this error?
let headers = new Headers({ ‘Content-Type’: ‘application/json’ });
let options = new RequestOptions({ headers: headers });
//Pass the data into the API and creat the user
if(url != "" && url != undefined){
this.http.post(url, object, options).subscribe(data => {
console.log(data);
}, error => {
console.log(error);
});
}
Sir have add “proxies”: [
{
“path”: “/api”,
“proxyUrl”: “http://cors.api.com/api”
}
]
in our ionic.config.json file but i got another error here
Argument of type ‘{ headers: Headers; }’ is not assignable to parameter of type ‘RequestOptionsArgs’.
I’m have the same error on Ionic 4.0.0-BETA2 for Edge Browser
I’m try to put this on ionic.config.json but didn’t solve my problem.
The problem is with the HTTP request. When I try to do a GET request I received an console error. See the details:
My .ts code
this.http
.get<any[]>(this.url) //the return is an array
.pipe(map(data => data[0]))
.subscribe(
value => {
console.log(value); //this line is not called
}
)
@amitgsk: sir i fixed it actually its a backend issue not at the front end issue.actually at backend side ‘Access-origin’ is not added at backend so discuss with backend developer and set access origin at backend.
Thank you for replying I have solved this issue using this post Ionic3 + HTTP call + Android 9.0.4
I do have CORS handled in back end because am myself also developing the back end with the help of Web Api 2 if you have any thing more suggestion please let me know.