Fix Shop fetching on server side?
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
import { fetchAPI } from '$utils/api'
|
import { fetchAPI } from '$utils/api'
|
||||||
import { getProducts } from '$utils/functions/shop'
|
import { initSwell, getProducts } from '$utils/functions/shop'
|
||||||
|
|
||||||
export const load: PageServerLoad = async () => {
|
export const load: PageServerLoad = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -55,6 +55,7 @@ export const load: PageServerLoad = async () => {
|
|||||||
/**
|
/**
|
||||||
* Get products data from Swell
|
* Get products data from Swell
|
||||||
*/
|
*/
|
||||||
|
initSwell()
|
||||||
const shopProducts = await getProducts('posters')
|
const shopProducts = await getProducts('posters')
|
||||||
|
|
||||||
if (shopProducts) {
|
if (shopProducts) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
import { fetchAPI } from '$utils/api'
|
import { fetchAPI } from '$utils/api'
|
||||||
import { getProduct } from '$utils/functions/shop'
|
import { initSwell, getProduct } from '$utils/functions/shop'
|
||||||
import { getRandomItem } from '$utils/functions'
|
import { getRandomItem } from '$utils/functions'
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({}) => {
|
export const load: PageServerLoad = async ({}) => {
|
||||||
@@ -39,6 +39,7 @@ export const load: PageServerLoad = async ({}) => {
|
|||||||
const randomPoster: any = getRandomItem(data.data.posters)
|
const randomPoster: any = getRandomItem(data.data.posters)
|
||||||
|
|
||||||
// Fetch Swell API for product
|
// Fetch Swell API for product
|
||||||
|
initSwell()
|
||||||
const shopProduct = await getProduct(randomPoster.product_id)
|
const shopProduct = await getProduct(randomPoster.product_id)
|
||||||
|
|
||||||
if (shopProduct) {
|
if (shopProduct) {
|
||||||
|
|||||||
Reference in New Issue
Block a user