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

Calls in await Promise.all with .map with different params returns same.

Open Neeil opened this issue 5 years ago • 0 comments

I tried to use await Promise.all with .map to call the api with multi different params. And when try to mock the response, the mock replies two same results with different param.

The following is the code and console snips.

I do have such a call in vue stor const dictsData = await Promise.all( //todo: there is something wrong here. names.map(name => { console.log('API:',name) api.DICTDATA_ALL({ page_size: 9999, dict_type: name }) } ) )

And this is my mock handler mock.onAny('/api/dictData/index').reply(config => { console.log('API Mock Data') console.log(query) if (query.dict_id) { let data = getDictData(query.dict_id) if (data != null) { return tools.responseSuccess(data) } else { return tools.responseError() } } else if (query.dict_type) { let data = getDictBytype(query.dict_type) return tools.responseSuccess(data) } }) return requestForMock({ url: '/api/dictData/index', method: 'post', data: query })

The following is the browser log: Snipaste_2020-07-31_14-10-05.png

Neeil avatar Jul 31 '20 06:07 Neeil