Relying on 3rd party services to handle some part of your business logic is a common practice. You might use SendGrid to send emails, Google Cloud Bucket Storage api to store some binary blob or Twilio for sending SMS to your users.
Although, the three I mentioned above are quite reliable, you might find yourself in a situration where any of these thre or the external resource you are relying on rejects your request with the dreaded
503 Serice Unavailable message.
Assuming everything is good on your side, you might want to retry that HTTP API request.
This is how you do that.
const https = require('https');
You can call this function as the standard https request in node.js,
The function will retry itself after failure three times before giving up.
Of course, this is just for your knowledge. In real life, you should probably use a well known package for this kind of stuff. I’d recommend one of these: