bruno/renderer/api/base.js

28 lines
582 B
JavaScript
Raw Normal View History

2022-03-07 15:32:39 +01:00
import axios from "axios";
const apiClient = axios.create({
2022-03-07 21:52:21 +01:00
baseURL: process.env.NEXT_PUBLIC_GRAFNODE_SERVER_API
2022-03-07 15:32:39 +01:00
});
apiClient.interceptors.request.use((config) => {
const headers = {
'Content-Type': 'application/json'
};
return ({
...config,
headers: headers
});
}, error => Promise.reject(error));
apiClient.interceptors.response.use((response) =>
response,
async (error) => {
return Promise.reject(error.response ? error.response.data : error);
}
);
const { get, post, put, delete: destroy } = apiClient;
export { get, post, put, destroy };