You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
506 B
26 lines
506 B
import axios from 'axios'; |
|
import dotenv from 'dotenv'; |
|
dotenv.config(); |
|
const { BASE_URL, TOKEN } = process.env; |
|
|
|
const config = { |
|
baseURL: BASE_URL, |
|
headers: { authorization: `Bearer ${TOKEN}` }, |
|
}; |
|
|
|
const axiosWrapper = async ({ method, url, payload, responseType }) => { |
|
try { |
|
return await axios({ |
|
method, |
|
url, |
|
...config, |
|
data: { ...payload }, |
|
responseType, |
|
}); |
|
} catch (error) { |
|
console.error(error); |
|
return null; |
|
} |
|
}; |
|
|
|
export { axiosWrapper };
|
|
|