diff --git a/pairent_frontend_react/src/API/User.js b/pairent_frontend_react/src/API/User.js new file mode 100644 index 0000000..0f029f8 --- /dev/null +++ b/pairent_frontend_react/src/API/User.js @@ -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); + } +} \ No newline at end of file