add user api wrapper

This commit is contained in:
b1ek 2023-05-15 16:53:49 +10:00
parent 5cd15a5615
commit 290e53b14f
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 17 additions and 0 deletions

View File

@ -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);
}
}