We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I have an issue when trying to add a new mock route. Cannot hit API mock with the new route but existing route is working.
My mock implementation (index.js)
index.js
import MockRoutes from './mock-routes' import axios from 'axios' import MockAdapter from 'axios-mock-adapter' let routes = MockRoutes // axios mock method const mock = new MockAdapter(axios) const methodMap = { GET: 'onGet', PUT: 'onPut', POST: 'onPost', DELETE: 'onDelete' } function applyMock (data) { data.forEach(d => { const params = [d.url] switch (d.method) { case 'GET': params.push({ params: d.param_values }) break case 'PUT' || 'POST': params.push(d.param_values) break } mock[methodMap[d.method]](...params).reply(d.status || 200, d.response) }) } applyMock(routes) if (process.env.NODE_ENV !== 'production') { window.concatMockRoutes = function (newRoutes) { applyMock(newRoutes) routes = routes.concat(newRoutes) if (process.env.NODE_ENV !== 'production') { return routes } } } export default routes
Mock routes (mock-routes.js)
mock-routes.js
var routes = [ { method: 'GET', url: '/route/existing', response: { "code": 200, "status": "OK", "data": { mock: "existing" } } }, { method: 'GET', url: '/route/new', response: { "code": 200, "status": "OK", "data": { mock: "new" } } }]
Currently /route/existing is working but /route/new is not working Is there any solution to this? Anyone also had experienced this before?
/route/existing
/route/new
Project details: Vue.js version 2.5 Node.js version 14 Axios mock adapter version 1.17.0 Axios version 0.19.2
Thanks before
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, I have an issue when trying to add a new mock route. Cannot hit API mock with the new route but existing route is working.
My mock implementation (
index.js
)Mock routes (
mock-routes.js
)Currently
/route/existing
is working but/route/new
is not workingIs there any solution to this? Anyone also had experienced this before?
Project details:
Vue.js version 2.5
Node.js version 14
Axios mock adapter version 1.17.0
Axios version 0.19.2
Thanks before
The text was updated successfully, but these errors were encountered: