Update npm packages and code for newest SvelteKit updates

This commit is contained in:
2022-01-24 22:18:09 +01:00
parent f3d26d4377
commit 1a37a7d5b8
3 changed files with 132 additions and 137 deletions

View File

@@ -21,16 +21,16 @@ export async function get ({ url, body }) {
/**
* POST request
*/
export async function post ({ headers, url, body, params, ...rest }) {
export async function post ({ request, params }) {
try {
const bodyParsed = JSON.parse(Buffer.from(body).toString())
const { action, cartId, productId } = bodyParsed
const body = await request.json()
const { action, cartId, productId } = body
let result = {}
if (bodyParsed) {
if (body) {
switch (action) {
case 'getProducts': {
result = await getProducts(bodyParsed.category)
result = await getProducts(body.category)
break
}
case 'getProduct': {
@@ -46,11 +46,11 @@ export async function post ({ headers, url, body, params, ...rest }) {
break
}
case 'addToCart': {
result = await addToCart(cartId, productId, bodyParsed.quantity)
result = await addToCart(cartId, productId, body.quantity)
break
}
case 'updateCartItem': {
result = await updateCartItem(cartId, productId, bodyParsed.quantity)
result = await updateCartItem(cartId, productId, body.quantity)
break
}
case 'removeCartItem': {