Formatting and typing to make linter happy v2
This commit is contained in:
		
						commit
						ff00b984fe
					
				
					 1 changed files with 24 additions and 1 deletions
				
			
		|  | @ -33,6 +33,8 @@ interface API { | |||
|     username: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project[]>>; | ||||
|   /** Login */ | ||||
|   login(NewUser: NewUser): Promise<APIResponse<JSON>>; | ||||
| } | ||||
| 
 | ||||
| // Export an instance of the API
 | ||||
|  | @ -156,7 +158,7 @@ export const api: API = { | |||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   submitWeeklyReport: function ( | ||||
|   async submitWeeklyReport( | ||||
|     project: NewWeeklyReport, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project>> { | ||||
|  | @ -189,4 +191,25 @@ export const api: API = { | |||
|       }); | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async login(NewUser: NewUser): Promise<APIResponse<JSON>> { | ||||
|     try { | ||||
|       const response = await fetch("/api/login", { | ||||
|         method: "POST", | ||||
|         headers: { | ||||
|           "Content-Type": "application/json", | ||||
|         }, | ||||
|         body: JSON.stringify(NewUser), | ||||
|       }); | ||||
| 
 | ||||
|       if (!response.ok) { | ||||
|         return { success: false, message: "Failed to login" }; | ||||
|       } else { | ||||
|         const data = (await response.json()) as JSON; | ||||
|         return { success: true, data }; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return Promise.resolve({ success: false, message: "Failed to login" }); | ||||
|     } | ||||
|   }, | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus