forked from crowetic/commerce
Updated config in operations
This commit is contained in:
parent
385fd10fce
commit
b1e6aa25b5
@ -25,7 +25,7 @@ const cartApi: BigcommerceApiHandler = async (req, res, config) => {
|
|||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof BigcommerceApiError && error.status === 404) {
|
if (error instanceof BigcommerceApiError && error.status === 404) {
|
||||||
// The cookie exists but the cart wasn't found, so, remove the cookie
|
// Remove the cookie if it exists but the cart wasn't found
|
||||||
res.setHeader('Set-Cookie', getCartCookie(name))
|
res.setHeader('Set-Cookie', getCartCookie(name))
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
|
@ -33,11 +33,12 @@ async function getAllProductPaths<T, V = any>(opts: {
|
|||||||
|
|
||||||
async function getAllProductPaths({
|
async function getAllProductPaths({
|
||||||
query = getAllProductPathsQuery,
|
query = getAllProductPathsQuery,
|
||||||
config = getConfig(),
|
config,
|
||||||
}: {
|
}: {
|
||||||
query?: string
|
query?: string
|
||||||
config?: BigcommerceConfig
|
config?: BigcommerceConfig
|
||||||
} = {}): Promise<GetAllProductPathsResult<GetAllProductPathsQuery>> {
|
} = {}): Promise<GetAllProductPathsResult<GetAllProductPathsQuery>> {
|
||||||
|
config = getConfig(config)
|
||||||
// RecursivePartial forces the method to check for every prop in the data, which is
|
// RecursivePartial forces the method to check for every prop in the data, which is
|
||||||
// required in case there's a custom `query`
|
// required in case there's a custom `query`
|
||||||
const data = await config.fetch<RecursivePartial<GetAllProductPathsQuery>>(
|
const data = await config.fetch<RecursivePartial<GetAllProductPathsQuery>>(
|
||||||
|
@ -60,12 +60,13 @@ async function getAllProducts<T, V = any>(opts: {
|
|||||||
async function getAllProducts({
|
async function getAllProducts({
|
||||||
query = getAllProductsQuery,
|
query = getAllProductsQuery,
|
||||||
variables: vars,
|
variables: vars,
|
||||||
config = getConfig(),
|
config,
|
||||||
}: {
|
}: {
|
||||||
query?: string
|
query?: string
|
||||||
variables?: ProductVariables
|
variables?: ProductVariables
|
||||||
config?: BigcommerceConfig
|
config?: BigcommerceConfig
|
||||||
} = {}): Promise<GetAllProductsResult<GetAllProductsQuery>> {
|
} = {}): Promise<GetAllProductsResult<GetAllProductsQuery>> {
|
||||||
|
config = getConfig(config)
|
||||||
const variables: GetAllProductsQueryVariables = {
|
const variables: GetAllProductsQueryVariables = {
|
||||||
...config.imageVariables,
|
...config.imageVariables,
|
||||||
...vars,
|
...vars,
|
||||||
|
@ -56,12 +56,13 @@ async function getProduct<T, V = any>(opts: {
|
|||||||
async function getProduct({
|
async function getProduct({
|
||||||
query = getProductQuery,
|
query = getProductQuery,
|
||||||
variables: { slug, ...vars },
|
variables: { slug, ...vars },
|
||||||
config = getConfig(),
|
config,
|
||||||
}: {
|
}: {
|
||||||
query?: string
|
query?: string
|
||||||
variables: ProductVariables
|
variables: ProductVariables
|
||||||
config?: BigcommerceConfig
|
config?: BigcommerceConfig
|
||||||
}): Promise<GetProductResult<GetProductQuery>> {
|
}): Promise<GetProductResult<GetProductQuery>> {
|
||||||
|
config = getConfig(config)
|
||||||
const variables: GetProductQueryVariables = {
|
const variables: GetProductQueryVariables = {
|
||||||
...config.imageVariables,
|
...config.imageVariables,
|
||||||
...vars,
|
...vars,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user