mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.0.3
- Clean up login/redirect flow - Add redirect when not authed on other endpoints - Add GET /stats endpoint for overal stats
This commit is contained in:
parent
5fd9d41069
commit
038823055a
23 changed files with 413 additions and 178 deletions
29
web/src/Actions/api.js
Normal file
29
web/src/Actions/api.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { toast } from 'react-toastify';
|
||||
import ApiService from "../Services/api.service";
|
||||
|
||||
export const getStats = () => () => {
|
||||
return ApiService.getStats().then(
|
||||
(data) => {
|
||||
console.log(data);
|
||||
if (data.error) {
|
||||
toast.error(data.error)
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
(error) => {
|
||||
const message =
|
||||
(error.response &&
|
||||
error.response.data &&
|
||||
error.response.data.message) ||
|
||||
error.message ||
|
||||
error.toString();
|
||||
console.log(message);
|
||||
|
||||
toast.error(message);
|
||||
return Promise.reject();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue