UserService.js 956 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import axios from "axios";
  2. const UserService = axios.create({
  3. withCredentials: true,
  4. baseURL: `https://api.amic.ru/api/v1`,
  5. headers: {
  6. "key":"Accept",
  7. "value":"application/json",
  8. "description":"",
  9. "type":"text",
  10. "enabled":true
  11. },
  12. });
  13. export default {
  14. registration(user) {
  15. return UserService.post("/user/authorization/register", {
  16. email: user.email,
  17. first_name: user.firstName,
  18. password_a: user.password_a,
  19. password_b: user.password_b,
  20. })
  21. .then(response => {
  22. return response;
  23. })
  24. .catch(error => {
  25. console.log(error)
  26. });
  27. },
  28. login(user) {
  29. return UserService.post("/user/authorization/login", {
  30. email: user.email,
  31. password: user.password
  32. })
  33. .then((response) => {
  34. console.log(response.data.data.AcessToken)
  35. return response.data.data.AcessToken
  36. })
  37. .catch((error) => {
  38. console.log(error)
  39. })
  40. },
  41. };