|
@@ -1,6 +1,6 @@
|
|
|
import { toast } from 'react-toastify';
|
|
|
const axios = require('axios');
|
|
|
-axios.defaults.baseURL = 'http://localhost:3000';
|
|
|
+axios.defaults.baseURL = 'http://localhost:3000/api';
|
|
|
|
|
|
const error = (message:string) =>
|
|
|
toast.error(`🔥 ${message}!`, {
|
|
@@ -39,7 +39,7 @@ const authorizeUser = async (number:string,country:string):Promise<string | unde
|
|
|
success(`check ${number}`);
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
- error('bad request');
|
|
|
+ error('BAD REQUEST');
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -53,24 +53,21 @@ const loginUser = async <T>(number:string,code:string):Promise<T | undefined> =>
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const updateCredentials = async <T>(name: string,lastName: string):Promise<T | undefined> => {
|
|
|
+const updateCredentials = async (name: string,lastName: string):Promise<void> => {
|
|
|
try {
|
|
|
- const { data } = await axios.patch('/users/current', { name, lastName });
|
|
|
+ await axios.patch('/users/current', { name, lastName });
|
|
|
success(`CREDENTIALS UPDATED`);
|
|
|
- console.log(data)
|
|
|
- return data;
|
|
|
} catch (e) {
|
|
|
- console.log(e)
|
|
|
- error('bad request');
|
|
|
+ error('BAD REQUEST');
|
|
|
}
|
|
|
};
|
|
|
-const updateUserAvatar = async <T>(avatarFile: object):Promise<T | undefined> => {
|
|
|
+
|
|
|
+const updateUserAvatar = async (file: object):Promise<void> => {
|
|
|
try {
|
|
|
- const { data } = await axios.patch('/users/avatars', avatarFile);
|
|
|
+ await axios.patch('/users/avatar', file);
|
|
|
success(`AVATAR UPDATED`);
|
|
|
- return data;
|
|
|
} catch (e) {
|
|
|
- error('bad request');
|
|
|
+ error('BAD REQUEST');
|
|
|
}
|
|
|
};
|
|
|
|