I have several different API calls all goes to the same url, which is /api
. What differentiates them is in their request body, where there is a path
specified for each different API call. So the request looks like this
url: '/api',
method: 'POST',
headers: ...,
body: {
headers: {X-Amz-User-Agent: ".", Content-Type: "application/json"}
method: "GET"
operation: "describeEndpoint"
path: "/endpoint"
region: "us-east-1"
}
And I know I can use cy.route
to stub out API calls like this
cy.route({
method: 'POST',
url: '/api',
status: 500,
response: {},
})
But since there are many other API calls also go to this endpoint '/api'
, I want it to be specifically targeted to the describeEndpoint
call, which has "/endpoint"
in its path
so this stub doesn't affect other API calls. I wonder if it is possible to do it with cy.route
.
By the way does anyone know why is it that the method
in the request is POST
while the method
in the request body
is GET
? This is how the API request looks like in my app and I cannot understand the discrepancy here