yeh boi
This commit is contained in:
1 parent
30bf7426e4
commit
323c7877b1
13 files changed
+94
-52
No files matched your search
+13
-13
@@ -1,5 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import type { AxiosInstance } from 'axios';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
|
||||
type ApiResponse = [string | null, any | null];
|
||||
|
||||
@@ -20,20 +19,17 @@ const api = axios.create({
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
// axios.interceptors.request.use(function onReq(config) {
|
||||
// return config;
|
||||
// }, function onError(error) {
|
||||
// // console.error(error);
|
||||
// Promise.resolve(['Network Error', null]);
|
||||
// });
|
||||
|
||||
api.interceptors.response.use(function onSuccess(response) {
|
||||
function onSuccess(response) {
|
||||
return [null, response.data];
|
||||
}, function onError(error) {
|
||||
// console.error(error);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
if (error.response) return [error.response.data.error, null];
|
||||
if (error.request) return ['Network Error', null];
|
||||
});
|
||||
return ['Unknown Error', null];
|
||||
}
|
||||
|
||||
api.interceptors.response.use(onSuccess, onError);
|
||||
|
||||
const actions = {
|
||||
getBundles: async function getBundles() {
|
||||
@@ -52,6 +48,10 @@ const actions = {
|
||||
return api.get('/want/all');
|
||||
},
|
||||
|
||||
postWantSearch: async function postWantSearch(artist, title) {
|
||||
return api.post('/want/search', { artist, title });
|
||||
},
|
||||
|
||||
postWant: async function postWant(releaseId) {
|
||||
return api.post('/want', { releaseId });
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user