Changes
- It is now possible to set the http method of your
source()
<!-- +page.svelte -->
<script>
import { source } from 'sveltekit-sse'
const connection = source('/issue-55/events', {
options: {
method: 'GET', // The default is POST.
},
})
const message = connection.select('message')
</script>
<h3>{$message}</h3>
import { produce } from 'sveltekit-sse'
import { delay } from '$lib/delay.js'
export async function GET() { // Then you can use GET here.
return produce(async function start({ emit }) {
while (true) {
const { error } = emit('message', `${Date.now()}`)
if (error) {
return
}
await delay(1000)
}
})
}