{mastodon,flavours/glitch/util}/api.js: Remove csrf-token query
This commit is contained in:
parent
3893e49a1f
commit
9377b5ca7b
2 changed files with 4 additions and 28 deletions
|
@ -1,5 +1,4 @@
|
|||
import axios from 'axios';
|
||||
import ready from './ready';
|
||||
import LinkHeader from 'http-link-header';
|
||||
|
||||
export const getLinks = response => {
|
||||
|
@ -12,21 +11,10 @@ export const getLinks = response => {
|
|||
return LinkHeader.parse(value);
|
||||
};
|
||||
|
||||
let csrfHeader = {};
|
||||
|
||||
function setCSRFHeader() {
|
||||
const csrfToken = document.querySelector('meta[name=csrf-token]');
|
||||
if (csrfToken) {
|
||||
csrfHeader['X-CSRF-Token'] = csrfToken.content;
|
||||
}
|
||||
}
|
||||
|
||||
ready(setCSRFHeader);
|
||||
|
||||
export default getState => axios.create({
|
||||
headers: Object.assign(csrfHeader, getState ? {
|
||||
headers: getState ? {
|
||||
'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`,
|
||||
} : {}),
|
||||
} : {},
|
||||
|
||||
transformResponse: [function (data) {
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import axios from 'axios';
|
||||
import LinkHeader from 'http-link-header';
|
||||
import ready from './ready';
|
||||
|
||||
export const getLinks = response => {
|
||||
const value = response.headers.link;
|
||||
|
@ -12,21 +11,10 @@ export const getLinks = response => {
|
|||
return LinkHeader.parse(value);
|
||||
};
|
||||
|
||||
let csrfHeader = {};
|
||||
|
||||
function setCSRFHeader() {
|
||||
const csrfToken = document.querySelector('meta[name=csrf-token]');
|
||||
if (csrfToken) {
|
||||
csrfHeader['X-CSRF-Token'] = csrfToken.content;
|
||||
}
|
||||
}
|
||||
|
||||
ready(setCSRFHeader);
|
||||
|
||||
export default getState => axios.create({
|
||||
headers: Object.assign(csrfHeader, getState ? {
|
||||
headers: getState ? {
|
||||
'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`,
|
||||
} : {}),
|
||||
} : {},
|
||||
|
||||
transformResponse: [function (data) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue