Skip to content

Instantly share code, notes, and snippets.

@PierBover
Created May 17, 2020
Embed
What would you like to do?
addEventListener('fetch', event => {
event.respondWith(streamResponse(event))
});
async function streamResponse (event) {
let readable = new ReadableStream({
start (controller) {
setInterval(() => {
controller.enqueue('Hello stream!' + '\n');
}, 1000);
}
});
return new Response(readable, {
status: 200
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment