Skip to content

Instantly share code, notes, and snippets.

@zzdjk6
Last active August 19, 2018 23:19
Show Gist options
  • Save zzdjk6/eecc97eede8ea2c3fa403ec9ba31db7d to your computer and use it in GitHub Desktop.
Save zzdjk6/eecc97eede8ea2c3fa403ec9ba31db7d to your computer and use it in GitHub Desktop.
Persisted GraphQL Queries with axios and SilverStripe 4: previous
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