I am attempting to edit an instance of Axios so that the response type should be a 'stream'
rather than standard JSON.
It doesn't seem clear to me from other posts on S.O. how this can be accomplished.
Is this a dead-end??
My Current Axios Instance :
import axios from 'axios';
import { URL } from '../urls';
import {
requestHandler,
successHandler,
errorHandler,
} from './Handlers';
const Api = axios.create({
baseURL: `${URL}`,
withCredentials: true,
});
Api.interceptors.request.use((request) => requestHandler(request));
Api.interceptors.response.use((response) => successHandler(response), (error) => errorHandler(error));
export default Api;
Implemented :
const query = {"selections":{"TABLE_A":["COLUMN1"]},"filters":[{"predicates":[]}],"joins":[],"sorts":[],"limit":100,"offset":0}
const response = await Api.post('/data', query);
The axios
signature for post looks like this :
axios.post(url[, data[, config]])
Example 1
Example 2
This signature doesn't seem to indicate that the newly created instance of axios
has a property relating to streams. Ideally, I would be able to do something like this:
const response = await Api.post(URL, responseType: 'stream', query);
or potentially :
const response = await Api(responseType: 'stream').post(URL, query);
stream
overarraybuffer
? This answer suggestsarraybuffer
is better thanblob
for binary images (https://mcmap.net/q/245188/-how-does-axios-handle-blob-vs-arraybuffer-as-responsetype) but is there an advantage tostream
overarraybuffer
for binary images? – Germiston