DEV Community

Discussion on: Using mocked APIs to increase developer productivity

Collapse
 
asantos00 profile image
Alexandre • Edited

That looks like a nice alternative. I tend to look for simpler solutions (that explains why I've used json-server).

After writing the article I remembered a better way to mock http requests without depending on axios, that is to basically to mock XMLHttpRequest. This way the application wouldn't know about it and it would not be bounded to axios interceptors.

Would love to read what you're writing on your solution

Collapse
 
rattanakchea profile image
Rattanak Chea

What do you mean mock XMLHttpRequest? Can you provide some more context? Like using this library npmjs.com/package/mock-xmlhttprequest for example?

Thread Thread
 
asantos00 profile image
Alexandre

Yes, that would be one option. Either that or something like PretenderJS does (github.com/pretenderjs/pretender/b...)