add user api wrapper
This commit is contained in:
parent
5cd15a5615
commit
290e53b14f
|
@ -0,0 +1,17 @@
|
|||
import axios from 'axios';
|
||||
import constants from '../constants';
|
||||
|
||||
const { API_ROOT } = constants;
|
||||
|
||||
class User {
|
||||
constructor(data) {
|
||||
this = { ...data, ...this };
|
||||
}
|
||||
|
||||
static async getById(id) {
|
||||
const data = await axios.post(API_ROOT + '/users/get', { id });
|
||||
if (data.data['error'])
|
||||
throw new Error(data.data['error']);
|
||||
return new User(data.data);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue