forked from crowetic/commerce
Fixed type
This commit is contained in:
parent
1569d62902
commit
316801627b
@ -20,40 +20,40 @@ const signup: SignupHandlers['signup'] = async ({
|
|||||||
|
|
||||||
let result: { data?: any } = {}
|
let result: { data?: any } = {}
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
result = await config.storeApiFetch('/v3/customers', {
|
// result = await config.storeApiFetch('/v3/customers', {
|
||||||
method: 'POST',
|
// method: 'POST',
|
||||||
body: JSON.stringify([
|
// body: JSON.stringify([
|
||||||
{
|
// {
|
||||||
first_name: firstName,
|
// first_name: firstName,
|
||||||
last_name: lastName,
|
// last_name: lastName,
|
||||||
email,
|
// email,
|
||||||
authentication: {
|
// authentication: {
|
||||||
new_password: password,
|
// new_password: password,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
]),
|
// ]),
|
||||||
})
|
// })
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
if (error instanceof BigcommerceApiError && error.status === 422) {
|
// if (error instanceof BigcommerceApiError && error.status === 422) {
|
||||||
const hasEmailError = '0.email' in error.data?.errors
|
// const hasEmailError = '0.email' in error.data?.errors
|
||||||
|
|
||||||
// If there's an error with the email, it most likely means it's duplicated
|
// // If there's an error with the email, it most likely means it's duplicated
|
||||||
if (hasEmailError) {
|
// if (hasEmailError) {
|
||||||
return res.status(400).json({
|
// return res.status(400).json({
|
||||||
data: null,
|
// data: null,
|
||||||
errors: [
|
// errors: [
|
||||||
{
|
// {
|
||||||
message: 'The email is already in use',
|
// message: 'The email is already in use',
|
||||||
code: 'duplicated_email',
|
// code: 'duplicated_email',
|
||||||
},
|
// },
|
||||||
],
|
// ],
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
throw error
|
// throw error
|
||||||
}
|
// }
|
||||||
|
|
||||||
console.log('DATA', result.data)
|
console.log('DATA', result.data)
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ export default async function fetchGraphqlApi<Q, V = any>(
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// console.log('HEADERS', getRawHeaders(res))
|
||||||
|
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
console.error(json.errors)
|
console.error(json.errors)
|
||||||
@ -27,3 +29,13 @@ export default async function fetchGraphqlApi<Q, V = any>(
|
|||||||
}
|
}
|
||||||
return json.data
|
return json.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRawHeaders(res: Response) {
|
||||||
|
const headers: { [key: string]: string } = {}
|
||||||
|
|
||||||
|
res.headers.forEach((value, key) => {
|
||||||
|
headers[key] = value
|
||||||
|
})
|
||||||
|
|
||||||
|
return headers
|
||||||
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { BigcommerceApiError } from '../../utils/errors'
|
import type { Wishlist, WishlistHandlers } from '..'
|
||||||
import type { WishlistList, WishlistHandlers } from '..'
|
|
||||||
|
|
||||||
// Return all wishlists
|
// Return all wishlists
|
||||||
const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
||||||
@ -7,10 +6,12 @@ const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
|||||||
body: { customerId },
|
body: { customerId },
|
||||||
config,
|
config,
|
||||||
}) => {
|
}) => {
|
||||||
let result: { data?: WishlistList } = {}
|
let result: { data?: Wishlist[] } = {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await config.storeApiFetch(`/v3/wishlists/customer_id=${customerId}`)
|
result = await config.storeApiFetch(
|
||||||
|
`/v3/wishlists/customer_id=${customerId}`
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user