4
0
forked from crowetic/commerce

Updated config in operations

This commit is contained in:
Luis Alvarez 2020-10-03 16:56:20 -05:00
parent 385fd10fce
commit b1e6aa25b5
4 changed files with 7 additions and 4 deletions

View File

@ -25,7 +25,7 @@ const cartApi: BigcommerceApiHandler = async (req, res, config) => {
)
} catch (error) {
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))
} else {
throw error

View File

@ -33,11 +33,12 @@ async function getAllProductPaths<T, V = any>(opts: {
async function getAllProductPaths({
query = getAllProductPathsQuery,
config = getConfig(),
config,
}: {
query?: string
config?: BigcommerceConfig
} = {}): Promise<GetAllProductPathsResult<GetAllProductPathsQuery>> {
config = getConfig(config)
// RecursivePartial forces the method to check for every prop in the data, which is
// required in case there's a custom `query`
const data = await config.fetch<RecursivePartial<GetAllProductPathsQuery>>(

View File

@ -60,12 +60,13 @@ async function getAllProducts<T, V = any>(opts: {
async function getAllProducts({
query = getAllProductsQuery,
variables: vars,
config = getConfig(),
config,
}: {
query?: string
variables?: ProductVariables
config?: BigcommerceConfig
} = {}): Promise<GetAllProductsResult<GetAllProductsQuery>> {
config = getConfig(config)
const variables: GetAllProductsQueryVariables = {
...config.imageVariables,
...vars,

View File

@ -56,12 +56,13 @@ async function getProduct<T, V = any>(opts: {
async function getProduct({
query = getProductQuery,
variables: { slug, ...vars },
config = getConfig(),
config,
}: {
query?: string
variables: ProductVariables
config?: BigcommerceConfig
}): Promise<GetProductResult<GetProductQuery>> {
config = getConfig(config)
const variables: GetProductQueryVariables = {
...config.imageVariables,
...vars,