Last active
August 19, 2018 23:19
-
-
Save zzdjk6/eecc97eede8ea2c3fa403ec9ba31db7d to your computer and use it in GitHub Desktop.
Persisted GraphQL Queries with axios and SilverStripe 4: previous
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
import StorageService from "./StorageService"; | |
export default class AxiosService { | |
static getInstance(query, variables) { | |
let headers = {}; | |
const user = StorageService.readUser(); | |
if (user && user.Token) { | |
headers["Authorization"] = "Bearer " + user.Token; | |
} | |
let data = { | |
query: query, | |
variables: variables | |
}; | |
return axios.create({ | |
url: "/graphql", | |
method: "post", | |
data: data, | |
headers: headers | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment