Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set request method: GET #321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

rjurado01
Copy link

@rjurado01 rjurado01 commented Jun 20, 2023

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:

image

Solves issue when uses with Msw library.
rjurado01 added a commit to nosoloforks/eventsource that referenced this pull request Jun 20, 2023
@rjurado01 rjurado01 changed the title Set request method: 'GET' Set request method: GET Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant