Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// helpers/api_helper.js
import axios from "axios";
//apply base url for axios
const REACT_APP_APP_URL = process.env.REACT_APP_APP_URL;
const axiosApi = axios.create({
baseURL: REACT_APP_APP_URL,
});
axios.interceptors.request.use(function (config) {
return config;
});
axiosApi.interceptors.response.use(
(response) => response,
(error) => Promise.reject(error)
);
export async function get(url, config) {
return await axiosApi
.get(url, {
...config,
})
.then((response) => response.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment