Hello,
I’m trying to figure out how I can call the REST API from inside a webhook handler.
I want to obtain, in the ORDERS_FULFILLED webhook, the customer’s metafields, so I’m trying to use the Find customer endpoint. The problem is that I don’t know how to handle the ‘session’ parameter of the library:
async function (topic, shop, body, webhookId) {
const order = JSON.parse(body);
if (!order.customer) {
return;
}
const customerId = order.customer.id;
const customer = await shopify.api.rest.Customer.find({
session,
id: customerId,
});
}
In the context of an API call made with AppBridge, I can use the variable “res.locals.shopify.session”, but I don’t know how to handle auth in the webhook context.
I’m using “@shopify/shopify-app-express” 2.1.0