Skip to content

Instantly share code, notes, and snippets.

@techomoro
Created October 8, 2021 09:42
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 techomoro/98bc495df5a79d3189e319f7a47fba74 to your computer and use it in GitHub Desktop.
Save techomoro/98bc495df5a79d3189e319f7a47fba74 to your computer and use it in GitHub Desktop.
// 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