aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-23 16:18:19 -0400
committerIvan Chen <ivan@tagg.id>2021-03-23 16:18:19 -0400
commit4844b69ed6c381fe8e573e77d32302965c4de274 (patch)
tree605f08e0019c877564a9631be604d83e67dd7caf /src/services
parent8022d908ca09860424529d818e210d63fff9f398 (diff)
updated types, using api/profile
Diffstat (limited to 'src/services')
-rw-r--r--src/services/UserProfileService.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts
index de24d2d6..e733cb47 100644
--- a/src/services/UserProfileService.ts
+++ b/src/services/UserProfileService.ts
@@ -7,6 +7,7 @@ import {
GET_TWITTER_POSTS_ENDPOINT,
HEADER_PHOTO_ENDPOINT,
PASSWORD_RESET_ENDPOINT,
+ USER_PROFILE_ENDPOINT,
PROFILE_INFO_ENDPOINT,
PROFILE_PHOTO_ENDPOINT,
REGISTER_ENDPOINT,
@@ -25,7 +26,7 @@ import {
SUCCESS_PWD_RESET,
SUCCESS_VERIFICATION_CODE_SENT,
} from '../constants/strings';
-import {SocialAccountType} from '../types';
+import {SocialAccountType, ProfileType} from '../types';
export const loadProfileInfo = async (token: string, userId: string) => {
try {
@@ -333,3 +334,24 @@ export const sendRegister = async (
return undefined;
}
};
+
+export const fetchUserProfile = async (userId: string, token?: string) => {
+ try {
+ if (!token) {
+ token = (await AsyncStorage.getItem('token')) ?? '';
+ }
+ const response = await fetch(USER_PROFILE_ENDPOINT + userId + '/', {
+ method: 'GET',
+ headers: {
+ Authorization: 'Token ' + token,
+ },
+ });
+ if (response.status === 200) {
+ const data: ProfileType = await response.json();
+ return data;
+ }
+ } catch (error) {
+ console.log(error);
+ return undefined;
+ }
+};