separating api utils from app logic

This commit is contained in:
2022-05-29 13:17:54 -05:00
parent d4121586cd
commit 9e295dde68
9 changed files with 39 additions and 33 deletions

View File

@@ -0,0 +1,20 @@
import { userInfo } from '../types/main';
export const getAllUsers = async () => {
let serverCall = await fetch('http://localhost:8088/users')
.then(res => res.json());
return serverCall;
}
export const registerNewUser = async (user: userInfo) => {
let serverCall = await fetch('http://localhost:8088/register', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(user)
});
if (serverCall.ok) return 'User added successfully.';
}