Modify the implementation of the changeUserName method in the api object
This commit is contained in:
		
							parent
							
								
									9e2a3cca81
								
							
						
					
					
						commit
						3e11b87eee
					
				
					 1 changed files with 21 additions and 5 deletions
				
			
		|  | @ -497,12 +497,28 @@ export const api: API = { | |||
|       }); | ||||
|     } | ||||
|   }, | ||||
|   changeUserName: function ( | ||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | ||||
|     _data: StrNameChange, | ||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | ||||
| 
 | ||||
|   async changeUserName( | ||||
|     data: StrNameChange, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<void>> { | ||||
|     throw new Error("Function not implemented."); | ||||
|     try { | ||||
|       const response = await fetch("/api/changeUserName", { | ||||
|         method: "PUT", | ||||
|         headers: { | ||||
|           "Content-Type": "application/json", | ||||
|           Authorization: "Bearer " + token, | ||||
|         }, | ||||
|         body: JSON.stringify(data), | ||||
|       }); | ||||
| 
 | ||||
|       if (!response.ok) { | ||||
|         return { success: false, message: "Failed to change username" }; | ||||
|       } else { | ||||
|         return { success: true }; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return { success: false, message: "Failed to change username" }; | ||||
|     } | ||||
|   }, | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 pavel Hamawand
						pavel Hamawand