Add project API interface in frontend
This commit is contained in:
		
							parent
							
								
									1c87380db7
								
							
						
					
					
						commit
						b5c2987281
					
				
					 2 changed files with 26 additions and 0 deletions
				
			
		|  | @ -1,3 +1,4 @@ | |||
| import { NewProject, Project } from "../Types/Project"; | ||||
| import { NewUser, User } from "../Types/Users"; | ||||
| 
 | ||||
| // Defines all the methods that an instance of the API must implement
 | ||||
|  | @ -6,6 +7,8 @@ interface API { | |||
|   registerUser(user: NewUser): Promise<User>; | ||||
|   /** Remove a user */ | ||||
|   removeUser(username: string): Promise<User>; | ||||
|   /** Create a project */ | ||||
|   createProject(project: NewProject): Promise<Project>; | ||||
| } | ||||
| 
 | ||||
| // Export an instance of the API
 | ||||
|  | @ -29,4 +32,14 @@ export const api: API = { | |||
|       body: JSON.stringify(username), | ||||
|     }).then((res) => res.json() as Promise<User>); | ||||
|   }, | ||||
| 
 | ||||
|   async createProject(project: NewProject): Promise<Project> { | ||||
|     return fetch("/api/project", { | ||||
|       method: "POST", | ||||
|       headers: { | ||||
|         "Content-Type": "application/json", | ||||
|       }, | ||||
|       body: JSON.stringify(project), | ||||
|     }).then((res) => res.json() as Promise<Project>); | ||||
|   }, | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus