I am trying to solve the following inconvenience that occurs when sending data to the server from a device
the error is
XMLHttpRequest can not load
http://10.0.0.0/MovilAppWS/api/Pedidos/Post. Response for preflight has invalid HTTP status code 405
the information is loaded from a SQLite database
Used codes
this code is to bring the orders of the database
OrdersSynchronize ()
{
this.database.RequestsSynchronize (). then ((data: any) => {
console.log (data);
this.postData = data;
}, (error) => {
console.log (error);
})
}
The following code is for sending data through a web service
var headers = new Headers ({
‘Content-Type’: ‘application / json’,
‘Access-Control-Allow-Origin’: ‘*’,
‘Access-Control-Allow-Headers’: ‘X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method’,
‘Access-Control-Allow-Methods’: ‘GET, POST, OPTIONS, PUT, DELETE’
});
// headers.append ('Content-Type', 'application / json', 'Access-Control-Allow-Origin');
const requestOptions = new RequestOptions ({headers: headers})
let url = "http://10.0.0.0/MovilAppWS/api/Pedidos/Post"
this.http.post (url, this.postData, requestOptions)
.map (res => res.json ()). subscribe (data => {
const toast = this.toastCtrl.create ({
message: 'Your request has been processed, we will contact you shortly.',
duration: 5000
position: 'top'
});
toast.present ();
},
err => {
const toast = this.toastCtrl.create ({
message: err,
duration: 5000
position: 'middle'
});
toast.present ();
});