Example component GenApiDemo on how to use the new API
This commit is contained in:
		
							parent
							
								
									d2b4bf2a89
								
							
						
					
					
						commit
						bc9b01d85a
					
				
					 1 changed files with 23 additions and 0 deletions
				
			
		
							
								
								
									
										23
									
								
								frontend/src/Containers/GenApiDemo.tsx
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								frontend/src/Containers/GenApiDemo.tsx
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | ||||||
|  | import { useEffect } from "react"; | ||||||
|  | import { GenApi } from "../API/GenApi"; | ||||||
|  | 
 | ||||||
|  | // Instantiation of the API
 | ||||||
|  | const api = new GenApi(); | ||||||
|  | 
 | ||||||
|  | export function GenApiDemo(): JSX.Element { | ||||||
|  |   // Sync wrapper around the loginCreate method
 | ||||||
|  |   const register = async (): Promise<void> => { | ||||||
|  |     const response = await api.login.loginCreate({ | ||||||
|  |       username: "admin", | ||||||
|  |       password: "admin", | ||||||
|  |     }); | ||||||
|  |     console.log(response.data); // This should be the inner type of the response
 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   // Call the wrapper
 | ||||||
|  |   useEffect(() => { | ||||||
|  |     void register(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   return <></>; | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus