Skip to content

stream-axiosStreaming requests made easy

A wrapper library based on axios providing out-of-the-box streaming request interfaces.

stream-axios logo

Why stream-axios?

Before (Native fetch)

javascript
const response = await fetch("/api/chat", {
  method: "POST",
  body: JSON.stringify({ msg: "hi" }),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  console.log(decoder.decode(value));
}
👉

After (stream-axios)

javascript
await request.stream({ url: "/api/chat", data: { msg: "hi" } }, (chunk) =>
  console.log(chunk),
);

Released under the MIT License.