Axios error handle sponsor proxy requests.

This commit is contained in:
softsimon 2020-11-15 14:31:34 +07:00
parent e7ddedaeb6
commit 0616b3c3b0
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -191,12 +191,20 @@ class Server {
} else {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'donations', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/donations', { responseType: 'stream' });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
})
.get(config.MEMPOOL.API_URL_PREFIX + 'donations/images/:id', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/donations/images/' + req.params.id, { responseType: 'stream' });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
});
}
}