timemanager-clientjs
v4.1.1
Published
Epitech's first project : TimeManager JS Client to request backend third party API
Downloads
6
Readme
Epitech's first project : TimeManager JS Client to request backend third party API
Create a new User :
import ClientAPI from 'timemanager-clientjs';
const api = ClientAPI.get()
const user = {
username: "Test_delete",
email: "[email protected]",
password: "dontuseazertyplease"
};
const [ createdUser, created ] = await api.register(user);
console.log(`Created user ${!created ? "(Erreur) " : ""} => \n`, createdUser);
const login = {
email: "[email protected]",
password: "dontuseazertyplease"
};
const [tokens] = await api.login(login);
console.log("Login => \n", tokens);
const [users] = await api.getUsers();
console.log("All users => \n", users);
const [newTokens, refreshed] = await api.refresh();
console.log(`Refreshed tokens ${!refreshed ? "(Erreur) " : ""} => \n`, newTokens);
const updateUser = {
username: "Updated"
};
const [updatedUser] = await api.updateUsers(updateUser);
console.log(updatedUser);
const [me, ok] = await api.me();
console.log(me, ok);
const api2 = ClientAPI.get(); // works because ClientAPI return a singleton
const [deleted] = await api2.deleteUsers();
console.log("Deleted user => ", deleted);