06-23-2018 03:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-23-2018 03:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello all, I am trying to post data using fetch. It appears a 400 error: Request not allowed.
I have checked headers and body and I can't solve the problem. Could anyone help me?
messaging.peerSocket.onmessage = function(evt) {
console.log(JSON.stringify(evt.data));
fetch('http://myserver.es:3000/mypost', {
method:'post',
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify(evt.data)
}).then(function(result) {
if (!result.ok) {
console.log(result.status + ': ' + result.statusText);
return;
}
console.log('Enviado paquete');
}).catch(function (err){
console.log(err)
})
}
Thanks all

06-24-2018 20:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-24-2018 20:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Just to give you a heads up and not sure if relevant to your problem, with iOS all network requests need to be done over SSL so try HTTPS.
06-25-2018 01:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-25-2018 01:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes, I think it is relevant, indeed I think it is the problem. I am actually using Android, not iOS, but I think it is necessary to do the network requests with https aswell. Thanks!

