mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
829 stars 52 forks source link

add req.query support #123

Closed af4oz closed 3 years ago

af4oz commented 3 years ago

GET /api/replies/test?thread_id=123

req.query is undefined

and also typescript issue

Property 'query' does not exist on type 'RestRequest<DefaultRequestBody, RequestParams>'
kettanaito commented 3 years ago

Hey, @zkindest.

MSW does not have a custom query property on the request object. Instead, we use the standard URLSearchParams under req.url.searchParams. Learn more about working with query parameters.

In your example, accessing the query parameters would look like this:

const threadId = req.url.searchParams.get('thread_id')