Skip to content

Mocking route with query params #316

@cmjio

Description

@cmjio

I am using MirageJS which uses pretender but the issue I think lies in pretender.

Trying to mock an API that uses RSQL as a query language. Requests look like the following /api/films?filter=genres=in=(comedy);actor=="Ryan Reynolds" with fairly complex query params. Is there any way to mock this exact URL?

I would have thought I could have done this.get('/films?filter=genres=in=(comedy);actor=="Ryan Reynolds"', () => {...}) but looks like the only route the will catch is mocking /films though currently using the request.queryParams it returns {filter: "genres"} and omits the rest of the query.

How might I, if at all mock API endpoints with specific queries appended to return different responses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions