Unverified Commit 5a36fd40 authored by Tamika Tannis's avatar Tamika Tannis Committed by GitHub

Fix error in handling the logged in user response (#142)

parent 97597e21
import axios, { AxiosResponse, AxiosError } from 'axios'; import axios, { AxiosResponse, AxiosError } from 'axios';
import { LoggedInUser, UserResponse } from '../types'; import { LoggedInUserResponse, UserResponse } from '../types';
export function getLoggedInUser() { export function getLoggedInUser() {
return axios.get(`/api/auth_user`) return axios.get(`/api/auth_user`)
.then((response: AxiosResponse<LoggedInUser>) => { .then((response: AxiosResponse<LoggedInUserResponse>) => {
return response.data; return response.data.user;
}).catch((error: AxiosError) => { }).catch((error: AxiosError) => {
return {}; return {};
}); });
......
...@@ -17,6 +17,7 @@ export interface User { ...@@ -17,6 +17,7 @@ export interface User {
} }
export type LoggedInUser = User & {}; export type LoggedInUser = User & {};
export type LoggedInUserResponse = { user: LoggedInUser; msg: string; };
export type UserResponse = { user: User; msg: string; }; export type UserResponse = { user: User; msg: string; };
/* getLoggedInUser */ /* getLoggedInUser */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment