Getting response as stream #1
Answered
by
fin-kafka
wannacfuture
asked this question in
Q&A
-
How can I get the stream-type response? I'm using axios. |
Beta Was this translation helpful? Give feedback.
Answered by
fin-kafka
Jun 3, 2023
Replies: 1 comment
-
Try this code snippet. const axios = require('axios'); axios({
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wannacfuture
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this code snippet.
const axios = require('axios');
const fs = require('fs');
axios({
method: 'get',
url: 'https://your-url.com/path/to/stream',
responseType: 'stream',
})
.then((response) => {
// Handle the stream as needed, e.g., save it to a file
const writeStream = fs.createWriteStream('output-file.ext');
response.data.pipe(writeStream);
})
.catch((error) => {
console.error('Error while fetching the stream:', error);
});