Created
November 27, 2021 08:12
-
-
Save agusrichard/cd95dd9f69c8bf08cecc068fd4eaa203 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const axios = require('axios') | |
const express = require('express') | |
const app = express() | |
app.get('/', async (req, res) => { | |
try { | |
await axios.get('http://localhost:3000') | |
res.send('Hello World!') | |
} catch (error) { | |
const status = error.response.status | |
if (status === 404) { | |
res.send('Not found') | |
} else if (status === 400) { | |
res.send('Bad request') | |
} else { | |
res.send('Something went wrong') | |
} | |
} | |
}) | |
app.listen(5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment