But I notice that the rule does not apply and I see a console error in browser: Uncaught (in promise) TypeError: Failed to fetch
Requestly seems to modify response only for APIs which return valid response and not for non-existent APIs.
Workaround is to create a mock API under Mocks section and specify the response. We get a public endpoint which we can use in our web application. But once the original API is ready, we would again need code changes to switch to original endpoint. To avoid this, we would need to create another rule which redirects original endpoint to mock endpoint.
This feature has been rolled out in Requestly.
Users may now create “Modify API Response” rule for non-existent APIs as well and consume the response in their UI application without even waiting for backend APIs to be ready.
Just to add, user may also define a dynamic response based on request parameters.
For instance, the response should return { productId: "123" } if request body sent { id: "123" }.