toverux / expresse

ExpreSSE: A better module for working with Server-Sent Events in Express
MIT License
48 stars 7 forks source link

Type error with vite-express on res.sse.x #9

Open eko2one opened 1 year ago

eko2one commented 1 year ago

I am using vite-express and having this issue when making a GET request from my frontend to the route:

      res.sse.data('ok', someEvent)
                ^
TypeError: Cannot read properties of undefined (reading 'data')

I have used Typescript import:

import { ISseResponse, sse } from '@toverux/expresse'
let someEvent = 'foo'
router.get('/check', sse({ flushAfterWrite: true }) ,(res: ISseResponse) => {

    setTimeout(() => {
        res.sse.data('ok', someEvent)

    }, 1000)

})