import axios from 'axios' ; import { ApiServerUrl } from './constants' ; const instance = axios . create ( { baseURL : ApiServerUrl , timeout : 10000 } ) ; export const apiAgent = { user : { async signUp ( user ) { return await instance . post ( '/user/signup' , user ) ; } , async signIn ( user ) { return await instance . post ( '/user/signin' , user ) ; } , async signOut ( payload ) { return await instance . post ( '/user/signout' , payload ) ; } , async get ( ) { return await instance . get ( '/user' ) ; } } , device : { async signIn ( user ) { return await instance . post ( '/device/signin' , user ) ; } } , utils : { async getCaptcha ( user ) { return await instance . post ( '/get_captcha' , user ) ; } } } ; export function setApiAgentToken ( token ) { instance . defaults . headers [ 'authorization' ] = `Token ${ token }` ; }