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.js 727B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import apiEndpoints from '../apiEndpoints';
  2. export const createUser = async (
  3. fullName,
  4. username,
  5. email,
  6. password,
  7. address,
  8. address2,
  9. city,
  10. country,
  11. postcode
  12. ) => {
  13. const response = await fetch(
  14. `http://localhost:3000${apiEndpoints.account.createUser}`,
  15. {
  16. method: 'POST',
  17. body: JSON.stringify({
  18. fullName,
  19. username,
  20. email,
  21. password,
  22. address,
  23. address2,
  24. city,
  25. country,
  26. postcode,
  27. }),
  28. headers: {
  29. 'Content-Type': 'application/json',
  30. },
  31. }
  32. );
  33. const data = await response.json();
  34. if (!response.ok) {
  35. throw new Error(data.message || 'Something went wrong!');
  36. }
  37. return data;
  38. };