My nock call looks like as below
app_url='myshop.app.com'
result = nock(app_url, {
reqheaders: {
"content-type": "application/json",
'authorization': 'Basic Auth'
}
})
.get('/admin/products.json?collection_id=10001&limit=250&fields=id')
.reply(200, {
"products": [
{ "id": 101},
{"id": 102},
]
});
Resolve :
(node:1378) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Nock: No match for request { .
But now,
==========updated=============
I have updated my call which is not throwing an error but now it is not intercepting the request….It is still hitting shopify to fetch the data
3
Answers
This happens when a nock matching the URL being hit is not found.
The url being hit is
as seen in the error message.
The URLs you are nocking do not correspond to it.
Something like this should work.
More details about the exact way to nock can be found in the Nock Documentation.
Just add flag in scope { allowUnmocked: true }
The nocked URL must be exactly the same as the URL that would be executed by Node in order to avoid the ‘Nock: No match for request’ error. So all you need to do is: