mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
backend: populated routes
This commit is contained in:
parent
723ab51eef
commit
6ffdca22d7
5 changed files with 25 additions and 9 deletions
|
@ -2,9 +2,16 @@ import axios from 'axios/index';
|
|||
|
||||
import { API } from '$constants/api';
|
||||
|
||||
const arrayToObject = (array, key) => array.reduce((obj, el) => ({ ...obj, [el[key]]: el }));
|
||||
|
||||
export const checkUserToken = ({ id, token }) => axios.get(API.CHECK_TOKEN, {
|
||||
params: { id, token }
|
||||
}).then(result => (result && result.data && { ...result.data, id, token }));
|
||||
}).then(result => (result && result.data && {
|
||||
...result.data,
|
||||
id,
|
||||
token,
|
||||
routes: (result.data.routes && result.data.routes.length > 0 && arrayToObject(result.data.routes, '_id')) || {},
|
||||
}));
|
||||
|
||||
export const getGuestToken = () => axios.get(API.GET_GUEST).then(result => (result && result.data));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue