mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-02 03:13:13 +03:00
update order of cookie and header adding
This commit is contained in:
parent
3139124132
commit
f118de7bf9
|
@ -8,6 +8,13 @@
|
||||||
x[key] = p[key] ? p[key].concat([value]) : [value];
|
x[key] = p[key] ? p[key].concat([value]) : [value];
|
||||||
return Object.assign(p, x);
|
return Object.assign(p, x);
|
||||||
}, {});
|
}, {});
|
||||||
|
var headers = {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
};
|
||||||
|
if (cookies.csrftoken && cookies.csrftoken.length) {
|
||||||
|
headers['X-CSRFToken'] = cookies.csrftoken.pop();
|
||||||
|
}
|
||||||
// Collect the URL parameters
|
// Collect the URL parameters
|
||||||
var parameters = {};
|
var parameters = {};
|
||||||
window.location.hash
|
window.location.hash
|
||||||
|
@ -47,13 +54,6 @@
|
||||||
|
|
||||||
// Defines a GraphQL fetcher using the fetch API.
|
// Defines a GraphQL fetcher using the fetch API.
|
||||||
function graphQLFetcher(graphQLParams) {
|
function graphQLFetcher(graphQLParams) {
|
||||||
var headers = {
|
|
||||||
Accept: 'application/json',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
};
|
|
||||||
if (cookies.csrftoken && cookies.csrftoken.length) {
|
|
||||||
headers['X-CSRFToken'] = cookies.csrftoken.pop();
|
|
||||||
}
|
|
||||||
function getFetch(headers) {
|
function getFetch(headers) {
|
||||||
return fetch(fetchURL, {
|
return fetch(fetchURL, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
@ -73,6 +73,7 @@
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (cookies.csrftoken && cookies.csrftoken.length) {
|
if (cookies.csrftoken && cookies.csrftoken.length) {
|
||||||
headers['X-CSRFToken'] = cookies.csrftoken.pop();
|
headers['X-CSRFToken'] = cookies.csrftoken.pop();
|
||||||
|
console.log('retry', headers)
|
||||||
return getFetch(headers);
|
return getFetch(headers);
|
||||||
}
|
}
|
||||||
return responseBody;
|
return responseBody;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user