mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add req.query support

af4oz opened this issue · comments

commented

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>'

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')