Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: axios
node v14.20.1
endpoint
share
tweet
const axios = require('axios'); const express = require('express'); const app = express(); app.get('/500', (req, res) => { res.status(500).send('Internal Server Error'); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); const test500 = async () => { try { const response = await axios.get('http://localhost:3000/500', { headers: { 'X-Custom-Header': 'foobar' }, }); console.log(response.data); } catch (error) { console.log(error.config.headers); await axios(error.config); } }; test500();
Created from: https://npm.runkit.com/axios
Loading…
Clone and edit this document