eventsource
eventsource copied to clipboard
Set request method: GET
Solves issue when uses with Msw library caused by this: link
Request headers are not sent when using the Msw library. Example:
const http = require('http')
const parse = require('url').parse // DEPRECATED !!
const setupServer = require('msw/node').setupServer
const server = setupServer()
beforeAll(() => {
server.listen()
})
afterAll(() => {
server.close()
})
it.only('test', async () => {
const url = parse('/')
url.protocol = 'http:'
url.host = '127.0.0.1'
url.hostname = '127.0.0.1'
url.port = '3000'
url.headers = {test: 'test'}
url.href = 'http://127.0.0.1:3000/'
// url.method = 'GET' // resolves the issue
const req = http.request(url, res => {
console.log(`STATUS: ${res.statusCode}`)
})
req.end()
})
Also it is sending hash parameter to null because it is using url.parse which by the way is deprecated: link: