Mocking jQuery AJAX with AmplifyJS Request

Web Dev .NET: Mocking jQuery AJAX with AmplifyJS Request.

The timeline of a recent project involved parallel development of a feature I was working on and the API I was to work with. Under normal circumstances this would have required my waiting for the API to be complete before I was able to fully do my part. My task involved an AJAX request to the API which would obtain certain attributes for a submitted product ID. I had to display those attributes in a certain way and also add them as form inputs for additional functionality.

To save time, the dev team I was working with set aside an initial block of time to come up with the data structure that’d get passed along the wire and sent it along to me. That way I’d have a mock response to work with and I could get started right away. This is where AmplifyJS comes in to play. It’s Request component allows you to simulate interactions with a remote API and account for any possible outcome. It also lets you randomize the data to better test your implementation and there are a lot of great features to keep in mind for your next project.