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