Created
August 18, 2018 01:26
-
-
Save neverendingqs/6cc14e919c8bb51f0ce038913404c6e9 to your computer and use it in GitHub Desktop.
2017/03/13/ensure-all-nock-interceptors-are-used.html - updatedserver.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const request = require('superagent'); | |
const express = require('express'); | |
const app = express(); | |
app.get('/', function(req, res) { | |
request | |
.get('https://www.example.com') | |
.then(response => res.send(response.text)) | |
// add a catch here and return a custom message | |
.catch(response => res.status(503).send('Please try again later.')); | |
}); | |
app.listen(3000); | |
module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment