diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/shopify.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/routes/shopify.js b/routes/shopify.js index f15a3468..a0aab057 100644 --- a/routes/shopify.js +++ b/routes/shopify.js @@ -1,4 +1,5 @@ import got from "got"; +import { g } from "$lib/db"; let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) { orderMarkAsPaid(input: $input) { @@ -10,20 +11,24 @@ let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) { } }`; -export default async ({ body, params: { id }, user }, res) => { - let r = await got.post( - `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, - { - headers: { - "Content-Type": "application/json", - "X-Shopify-Access-Token": user.shopifyToken - }, - json: { - query, - variables: { input: { id: `gid://shopify/Order/${id}` } } +export default async ({ body, params: { id, username } }, res) => { + let user = await g(`user:${await g(`user:${username}`)}`); + + let r = await got + .post( + `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, + { + headers: { + "Content-Type": "application/json", + "X-Shopify-Access-Token": user.shopifyToken + }, + json: { + query, + variables: { input: { id: `gid://shopify/Order/${id}` } } + } } - } - ).json(); + ) + .json(); res.send(r); }; |
