RunKit + npm: axios

node v14.20.1
endpointsharetweet
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…