mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
chore: 🤖 update env variables
This commit is contained in:
parent
f11ff29e3b
commit
9e68d2efbd
@ -1,6 +1,6 @@
|
||||
import type { CheckoutEndpoint } from '.'
|
||||
import getCredentials from '../../utils/getCredentials'
|
||||
import { Order } from '@commercelayer/js-sdk'
|
||||
import Order from '@commercelayer/sdk'
|
||||
|
||||
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
||||
req,
|
||||
@ -16,9 +16,9 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
||||
if (val.indexOf(name) === 0) accessToken = val.substring(name.length)
|
||||
})
|
||||
|
||||
const { endpoint } = getCredentials()
|
||||
const { ENDPOINT } = getCredentials()
|
||||
if (orderId && accessToken) {
|
||||
const clOrder = await Order.withCredentials({ endpoint, accessToken })
|
||||
const clOrder = await Order.withCredentials({ ENDPOINT, accessToken })
|
||||
.includes('lineItems')
|
||||
.find(orderId as string, { rawResponse: true })
|
||||
const checkoutUrl = clOrder.data.attributes.checkout_url
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Product } from '@vercel/commerce/types/Product'
|
||||
import { CONTENT_DATA_URL } from '../../const'
|
||||
|
||||
export type Products = (Product & { categoryId: string; brandId: string })[]
|
||||
|
||||
export default async function getContentData(id?: string): Promise<Products> {
|
||||
const url = process.env.NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL as string
|
||||
const products = (await (await fetch(url)).json()).products as Products
|
||||
const products = (await (await fetch(CONTENT_DATA_URL)).json()).products as Products
|
||||
return !id ? products : products.filter((p) => p.id === id)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { getCookie } from './cookies'
|
||||
import { ENDPOINT } from '../../const'
|
||||
|
||||
export default function getCredentials() {
|
||||
const endpoint = process.env.NEXT_PUBLIC_COMMERCELAYER_ENDPOINT as string
|
||||
const accessToken = getCookie('CL_TOKEN') as string
|
||||
return { accessToken, endpoint }
|
||||
return { accessToken, ENDPOINT }
|
||||
}
|
||||
|
||||
type ReturnObj = {
|
||||
|
@ -1,3 +1,4 @@
|
||||
export const ENDPOINT = process.env.NEXT_PUBLIC_COMMERCELAYER_ENDPOINT as string;
|
||||
export const CLIENTID = process.env.NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID as string;
|
||||
export const SCOPE = process.env.NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE as string;
|
||||
export const SCOPE = process.env.NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE as string;
|
||||
export const CONTENT_DATA_URL = process.env.NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL as string;
|
@ -50,4 +50,5 @@ NEXT_PUBLIC_COMMERCEJS_DEPLOYMENT_URL=
|
||||
|
||||
NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID=
|
||||
NEXT_PUBLIC_COMMERCELAYER_ENDPOINT=
|
||||
NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE=
|
||||
NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE=
|
||||
NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL=
|
Loading…
x
Reference in New Issue
Block a user