axios-mock-adapter icon indicating copy to clipboard operation
axios-mock-adapter copied to clipboard

implement ignoreQueryString as a boolean parameter

Open ikhnaton opened this issue 7 years ago • 1 comments

This submission allows the user to specify whether or not to ignore query parms when matching handlers. The new parameter can be specified as follows:

const mock = new MockAdapter(axios, {ignoreQueryString: true});

All tests pass.

ikhnaton avatar Sep 14 '18 06:09 ikhnaton

I'd like to have this kind of functionality, but on a per-request basis.

Not sure about the API though

// 1. ignore parameters if missing (breaking change)
onGet(someUrl) // ignore parameters
onGet(someUrl, {}) // require empty parameters
onGet(someUrl, { params: { x: 2 } }) // require some parameters

// 2. use a third parameter during requests to handle additional options
//    (less ergonomic but extensible with future options and not breaking change)
onGet(someUrl, null, { ignoreQueryString: true })
onGet(someUrl, { ... my params ... })

riquito avatar Oct 18 '18 21:10 riquito