Debugging fetch in a consumer

Yes, I'm awaiting the
fetch
and I also put inside a try/catch, but no error is logged.
The last log I see is the API URL log, and then the code skips everything below the log

try {
    console.log('API URL :', `${env.STRAPI_API_URL}/c-orders`);
    const connection = await fetch(`${env.STRAPI_API_URL}/c-orders`, {
      headers: {
        Authorization: `Bearer ${env.STRAPI_API_KEY}`,
        'Content-Type': 'application/json',
      },
      method: 'POST',
      body: JSON.stringify({
        data: {
          planId,
          date: new Date(),
          deliveryDate: new Date(deliveryDate * 1000),
          status: 1,
          details,
          grossPrice: totalPrice,
          finalPrice: totalPrice,
          subscriptionId: subscription ? strapiSubscriptionId : null,
          userId,
          paymentId: paymentIntent,
          paymentStatus: subscription ? 'processing' : 'success',
          orderInfo: [],
          stripeInvoiceId: invoice,
        },
      }),
    });

    console.log('connection :', connection);
    const data = await connection.json();
    console.log('data :', JSON.stringify(data, null, 2));

    if (connection.status !== 200) wasOrderCreated = false;

    wasOrderCreated = true;
  } catch (err) {
    console.log('err :', err);
    return false;
  }
Was this page helpful?