mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 13:41:22 +00:00
Updated urls to the API
This commit is contained in:
parent
cf9b341dc9
commit
746028f25b
@ -9,7 +9,7 @@ export default useLogin as UseLogin<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<LoginHook> = {
|
export const handler: MutationHook<LoginHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/customers/login',
|
url: '/api/login',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
},
|
},
|
||||||
async fetcher({ input: { email, password }, options, fetch }) {
|
async fetcher({ input: { email, password }, options, fetch }) {
|
||||||
|
@ -8,7 +8,7 @@ export default useLogout as UseLogout<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<LogoutHook> = {
|
export const handler: MutationHook<LogoutHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/customers/logout',
|
url: '/api/logout',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
useHook: ({ fetch }) => () => {
|
useHook: ({ fetch }) => () => {
|
||||||
|
@ -9,7 +9,7 @@ export default useSignup as UseSignup<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<SignupHook> = {
|
export const handler: MutationHook<SignupHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/customers/signup',
|
url: '/api/signup',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
},
|
},
|
||||||
async fetcher({
|
async fetcher({
|
||||||
|
@ -9,7 +9,7 @@ export default useAddItem as UseAddItem<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<AddItemHook> = {
|
export const handler: MutationHook<AddItemHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
},
|
},
|
||||||
async fetcher({ input: item, options, fetch }) {
|
async fetcher({ input: item, options, fetch }) {
|
||||||
|
@ -7,7 +7,7 @@ export default useCart as UseCart<typeof handler>
|
|||||||
|
|
||||||
export const handler: SWRHook<GetCartHook> = {
|
export const handler: SWRHook<GetCartHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
useHook: ({ useData }) => (input) => {
|
useHook: ({ useData }) => (input) => {
|
||||||
|
@ -20,7 +20,7 @@ export default useRemoveItem as UseRemoveItem<typeof handler>
|
|||||||
|
|
||||||
export const handler = {
|
export const handler = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
},
|
},
|
||||||
async fetcher({
|
async fetcher({
|
||||||
|
@ -6,7 +6,7 @@ import type {
|
|||||||
} from '@commerce/utils/types'
|
} from '@commerce/utils/types'
|
||||||
import { ValidationError } from '@commerce/utils/errors'
|
import { ValidationError } from '@commerce/utils/errors'
|
||||||
import useUpdateItem, { UseUpdateItem } from '@commerce/cart/use-update-item'
|
import useUpdateItem, { UseUpdateItem } from '@commerce/cart/use-update-item'
|
||||||
import type { LineItem, UpdateItemHook } from '../types'
|
import type { LineItem, UpdateItemHook } from '../types/cart'
|
||||||
import { handler as removeItemHandler } from './use-remove-item'
|
import { handler as removeItemHandler } from './use-remove-item'
|
||||||
import useCart from './use-cart'
|
import useCart from './use-cart'
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export default useUpdateItem as UseUpdateItem<typeof handler>
|
|||||||
|
|
||||||
export const handler = {
|
export const handler = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
},
|
},
|
||||||
async fetcher({
|
async fetcher({
|
||||||
|
@ -8,7 +8,7 @@ export default useWishlist as UseWishlist<typeof handler>
|
|||||||
|
|
||||||
export const handler: SWRHook<GetWishlistHook> = {
|
export const handler: SWRHook<GetWishlistHook> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/wishlist',
|
url: '/api/wishlist',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
async fetcher({ input: { customerId, includeProducts }, options, fetch }) {
|
async fetcher({ input: { customerId, includeProducts }, options, fetch }) {
|
||||||
|
@ -149,7 +149,7 @@ export const handler: SWRHook<
|
|||||||
{ isEmpty?: boolean }
|
{ isEmpty?: boolean }
|
||||||
> = {
|
> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
async fetcher({ input: { cartId }, options, fetch }) {
|
async fetcher({ input: { cartId }, options, fetch }) {
|
||||||
@ -197,7 +197,7 @@ export default useAddItem as UseAddItem<typeof handler>
|
|||||||
|
|
||||||
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
url: '/api/bigcommerce/cart',
|
url: '/api/cart',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
},
|
},
|
||||||
async fetcher({ input: item, options, fetch }) {
|
async fetcher({ input: item, options, fetch }) {
|
||||||
|
@ -43,12 +43,9 @@ export type HookFetcherFn<H extends HookSchemaBase> = (
|
|||||||
export type HookFetcherContext<H extends HookSchemaBase> = {
|
export type HookFetcherContext<H extends HookSchemaBase> = {
|
||||||
options: HookFetcherOptions
|
options: HookFetcherOptions
|
||||||
input: H['fetchInput']
|
input: H['fetchInput']
|
||||||
fetch: {
|
fetch: <T = H['fetchData'], B = H['body']>(
|
||||||
(
|
options: FetcherOptions<B>
|
||||||
options: FetcherOptions<H['body'] extends {} ? H['body'] : never>
|
) => Promise<T>
|
||||||
): Promise<H['fetchData'] extends {} | null ? H['fetchData'] : any>
|
|
||||||
<T = any, B = any>(options: FetcherOptions<B>): Promise<T>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HookFetcherOptions = { method?: string } & (
|
export type HookFetcherOptions = { method?: string } & (
|
||||||
|
@ -18,13 +18,13 @@ module.exports = withCommerceConfig({
|
|||||||
return [
|
return [
|
||||||
(isBC || isShopify) && {
|
(isBC || isShopify) && {
|
||||||
source: '/checkout',
|
source: '/checkout',
|
||||||
destination: '/api/bigcommerce/checkout',
|
destination: '/api/checkout',
|
||||||
},
|
},
|
||||||
// The logout is also an action so this route is not required, but it's also another way
|
// The logout is also an action so this route is not required, but it's also another way
|
||||||
// you can allow a logout!
|
// you can allow a logout!
|
||||||
isBC && {
|
isBC && {
|
||||||
source: '/logout',
|
source: '/logout',
|
||||||
destination: '/api/bigcommerce/customers/logout?redirect_to=/',
|
destination: '/api/logout?redirect_to=/',
|
||||||
},
|
},
|
||||||
// Rewrites for /search
|
// Rewrites for /search
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user