Closed philr35 closed 3 years ago
I am following the Shopify documentation here: https://shopify.dev/tutorials/manage-product-inventory-with-admin-api
- Am I calling the set function correctly?
Yes, it looks like you are using it correctly.
- Why is there no output?
I don't know, the request probably times out. Try to change the value of the timeout
option.
What version of shopify-api-node
and Node.js are you using? Try to see if it works with shopify-api-node@2
.
@lpinca This is what's inside of my dependencies:
"dependencies": {
"aws-serverless-express": "^3.3.5",
"body-parser": "^1.17.1",
"express": "^4.15.2",
"shopify-api-node": "^3.4.4"
}
I'll try shopify-api-node@2
. I'm using this inside of my AWS lambda function which is called by a Shopify webhook.
Try to change the value of the timeout option.
I see the default is 1minute until timeout, but the function exits way before that. So I don't think it's timing out. Perhaps it's exiting preemptively? But not sure why, since all my other GET requests work fine. Only when I try to update the inventory level does it not output anything.
I also confirmed the location_id was correct by doing postman request directly via shopify admin api. But even if it wasn't, there should be some sort of error, no?
Edit: Likewise if it succeeded, it should output something, right? I'm getting neither which is frustrating to troubleshoot
But even if it wasn't, there should be some sort of error, no?
Yes, the promise should be rejected with an error.
Likewise if it succeeded, it should output something, right?
Correct. It should return something like this https://github.com/MONEI/Shopify-api-node/blob/6428f553388eecc33a42d548a44abe59b14ce0c5/test/fixtures/inventory-level/res/set.json#L3-L6
I got it working. I tried doing hardcoded values, like so:
await shopifyInstance.inventoryLevel.set({ location_id: 47869067432, inventory_item_id: 36688460873896, available: 0 }).then(
res => {
console.log("SUCCESS:")
console.log(res)
},
err => {
console.log("ERROR:")
console.log(err)
}
)
And it was successful! I looked back at my original code, and indeed it does look like some promise issues in there that I need to sort out. Thanks for helping!
Hello, I'm encountering the same issue in the same situation. What I can do?
Hi, I'm trying to do something very simple. I'm trying to set all variants of a product to 0.
I'm using this code here:
For some reason,
inventoryLevel.set
is not outputting anything to my console. No responses, no error, nothing. Every console.log aboveinvetoryLevel.set
is being printed out just fine. I can't figure this one out.Questions: