You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

accountRequests.ts 651B

12345678910111213141516171819202122232425
  1. import { CreateUserResponse } from '../utils/interface/userInterface';
  2. import apiEndpoints from './apiEndpoints';
  3. export const createUser = async (
  4. fullName: string,
  5. username: string,
  6. email: string,
  7. password: string
  8. ): Promise<CreateUserResponse> => {
  9. const response = await fetch(apiEndpoints.account.createUser, {
  10. method: 'POST',
  11. body: JSON.stringify({ fullName, username, email, password }),
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. },
  15. });
  16. const data: CreateUserResponse = await response.json();
  17. if (!response.ok) {
  18. throw new Error(data.message || 'Something went wrong!');
  19. }
  20. return data;
  21. };