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 })
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: