MCPcopy Create free account
hub / github.com/John-Weeks-Dev/ebay-clone / useCreateAddress

Function useCreateAddress

app/hooks/useCreateAddress.js:1–22  ·  view source on GitHub ↗
(details)

Source from the content-addressed store, hash-verified

1const useCreateAddress = async (details) => {
2
3 let url = 'create'
4 if (details.addressId) url = 'update'
5
6 const response = await fetch(`/api/address/${url}`, {
7 method: 'POST',
8 headers: {'Content-Type': 'application/json'},
9 body: JSON.stringify({
10 addressId: details.addressId,
11 name: details.name,
12 address: details.address,
13 zipcode: details.zipcode,
14 city: details.city,
15 country: details.country,
16 })
17 })
18
19 const data = await response.json();
20
21 return data
22}
23
24export default useCreateAddress;

Callers 1

submitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected