jpfm
05/28/2017, 8:26 PM400 (Bad Request) with a CORS error.
return fetch(API_ENDPOINT_URL, {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: "{query: 'query { allUsers { id name } }'}",
})
When I add mode: 'no-cors', the request headers are immutable (see https://stackoverflow.com/questions/38156239/how-to-set-the-content-type-of-request-header-when-using-fetch-api) so I get a 415 (Unsupported Media Type) error because the Content-Type is text/plain.
return fetch(API_ENDPOINT_URL, {
method: 'post',
mode: 'no-cors',
headers: { // This does nothing
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: "{query: 'query { allUsers { id name } }'}",
})
How can I get up and running? Can't seem to find these issues documented anywhere.nilan
05/28/2017, 8:30 PMjpfm
05/28/2017, 8:30 PMnilan
05/28/2017, 8:30 PMAccept all together?jpfm
05/28/2017, 8:31 PMheaders object gets ignorednilan
05/28/2017, 8:32 PMjpfm
05/28/2017, 8:32 PMreturn fetch(API_ENDPOINT_URL, {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: "{query: 'query { allUsers { id name } }'}",
})jpfm
05/28/2017, 8:33 PMjpfm
05/28/2017, 8:33 PMjpfm
05/28/2017, 8:33 PMFetch API cannot load <https://api.graph.cool/simple/v1/>.... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<http://localhost:3000>' is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.nilan
05/28/2017, 8:35 PMnilan
05/28/2017, 8:36 PMJSON.stringifyjpfm
05/28/2017, 8:40 PMjpfm
05/28/2017, 8:40 PMjpfm
05/28/2017, 8:40 PMjpfm
05/28/2017, 8:40 PMnilan
05/28/2017, 8:41 PMnilan
05/28/2017, 8:41 PMjpfm
05/28/2017, 8:42 PMjpfm
05/28/2017, 8:42 PMjpfm
05/28/2017, 8:42 PMjpfm
05/28/2017, 8:42 PMnilan
05/28/2017, 8:42 PMnilan
05/28/2017, 8:43 PMnilan
05/28/2017, 8:43 PMjpfm
05/28/2017, 8:43 PMjpfm
05/28/2017, 8:44 PMGENERATE CODE button. opens a modal with some copypastanilan
05/28/2017, 8:45 PMjpfm
05/28/2017, 8:46 PM