Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const httpClient = (url, options = {}) => {
url = baseUrl(url)
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' })
}
const token = localStorage.getItem('token')
if (token) {
options.headers.set(customAuthorizationHeader, `Bearer ${token}`)
}
return fetchUtils.fetchJson(url, options).then((response) => {
const token = response.headers.get(customAuthorizationHeader)
if (token) {
const decoded = jwtDecode(token)
localStorage.setItem('token', token)
localStorage.setItem('userId', decoded.uid)
// Avoid going to create admin dialog after logout/login without a refresh
config.firstTime = false
}
return response
})
}
const httpClient = (url, options = {}) => {
if (!options.headers) {
options.headers = new Headers({ Accept: "application/json" });
}
const token = localStorage.getItem("token");
options.headers.set("Authorization", `Bearer ${token}`);
return fetchUtils.fetchJson(url, options);
};
useEffect(() => {
fetchUtils
.fetchJson(subsonic.url('getScanStatus'))
.then((resp) => resp.json['subsonic-response'])
.then((data) => {
if (data.status === 'ok') {
dispatch(scanStatusUpdate(data.scanStatus))
}
})
}, [dispatch])
const httpClient = (url: string, options: any = {}) => {
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' });
}
const token = localStorage.getItem('auth_token');
if (token !== null && token !== "") {
options.headers.set('Authorization', `Bearer ${token}`);
}
return fetchUtils.fetchJson(url, options);
};
const unstar = (id) => fetchUtils.fetchJson(url('unstar', id))