Skip to content

Instantly share code, notes, and snippets.

@themegabyte
Created June 4, 2023 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themegabyte/b7d8167eecf427fa16b0d8b9ebe24d77 to your computer and use it in GitHub Desktop.
Save themegabyte/b7d8167eecf427fa16b0d8b9ebe24d77 to your computer and use it in GitHub Desktop.
Directus SDK with Axios Interceptors.
import { Directus } from "@directus/sdk";
const DIRECTUS_ENDPOINT = process.env.DIRECTUS_HOST || "";
const DIRECTUS_TOKEN = process.env.DIRECTUS_TOKEN || "";
const directus = new Directus(DIRECTUS_ENDPOINT, {
auth: {
staticToken: DIRECTUS_TOKEN,
},
});
directus.transport.axios.interceptors.response.use((response) => {
console.log("inside response interceptor");
console.log("Response:", response);
console.log("exiting response interceptor");
return response;
});
export default directus;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment