diff options
| author | Adam Soltys <[email protected]> | 2023-09-20 16:13:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-09-20 16:13:58 -0700 |
| commit | 948efb0f123532c9f276831b485a9769cbe6b413 (patch) | |
| tree | 15293ec3c96ec1bf8c63703a3c1c8ac95a3c764f /routes | |
| parent | f990bf00785bc39b861a743bfb2c2c7f9e94d42c (diff) | |
| download | coinos-server-948efb0f123532c9f276831b485a9769cbe6b413.tar.gz coinos-server-948efb0f123532c9f276831b485a9769cbe6b413.zip | |
pass username to shopify endpoint
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); }; |
