Without knowing the entire code, it's hard to know exactly what may be the issue.
But a 401 or 403 error code indicates the API credentials are probably not passed in properly. For nodeJS, I recommend to use this library (https://github.com/MONEI/Shopify-api-node) to interact with Shopify APIs.
Additionally, I also recommend trying out a development platform we built for Shopify (Shypyard). The platform makes it dead simple for you to make API requests to your Shopify store. And you can use it to test and build your script easily all within your browser.