Ignore errors returned from API calls nodeJS Ignore errors returned from API calls nodeJS
I have a NodeJS script which is making thousands of REST API GET calls to SharePoint to retrieve all folders and files recursively. A problem I have encountered is once in a while I am receiving ECONNRESET errors and 404 Not Found for some folders with unsupported characters. This causes my code to stop and I lose my progress in retrieving all the files and folders. Is there something I can do to prevent these errors from stopping my code and just have it ignore the error and continue onto the next folder? I thought catching the error and console logging it would suffice but this still ends the execution of the code. Thanks //Imports and Declarations const prompt = require("prompt-sync")({ sigint: true }); const { getCreds, pullFromSharePoint } = require('./helper'); const sprequest = require('sp-request'); var path = require('path'); let creds = getCreds(); let spr = sprequest.create(creds) let SPUrl = 'url to sharepoint site'; let files = [...