How do i parse products/update webhook to backend server

Shopify Partner
2 0 0

Hi, I'm using Shopify's Remix App Template, and have setup a webhook for products updated. I want it to send the updated product to my backend server. However I'm having some issues doing so.


I get this error:

15:42:55 │ remix │ PRODUCTS_UPDATE error: SyntaxError: Unexpected token 'o', "[object Rea"... is not valid JSON

Request.body: ReadableStream { locked: true, state: 'closed', supportsBYOB: false }


Here is my case for product update:

console.log('PRODUCTS_UPDATE case called.');
    console.log('PRODUCTS_UPDATE called.');
    if ( !request.body ) {
        console.log('PRODUCTS_UPDATE request.body is null.', request.body);
    try {
        const product = JSON.parse(request.body.toString());
        console.log('PRODUCTS_UPDATE product:', product);
        const response = await
                store_url: shop,
                product: product

                headers: {
                    'Content-Type': 'application/json',
    }catch (error: unknown) {
    console.log('PRODUCTS_UPDATE error:', error)
    console.log("Request.body: ______" ,request.body, "______ REQUEST: ______", request, "______");
Replies 0 (0)