mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 14:14:06 +00:00
added session handling, some axios
This commit is contained in:
30
interceptors/axiosInstance.js
Normal file
30
interceptors/axiosInstance.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const { baseAPIURL } = require("../constants");
|
||||
|
||||
const axiosInstance = axios.default.create({
|
||||
baseURL: baseAPIURL,
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
const getHeaders = () => {
|
||||
let headers;
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
if (req.session.access_token) {
|
||||
headers = {
|
||||
...headers,
|
||||
'Authorization': req.session.access_token ? `Bearer ${req.session.access_token}` : '',
|
||||
}
|
||||
}
|
||||
|
||||
return headers;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
axiosInstance,
|
||||
getHeaders,
|
||||
};
|
||||
Reference in New Issue
Block a user