Cypress · Middle · Question 36 of 77
How do you call an API with auth in cy.request?
- 1
cy.requestalways reuses the page's login state only - 2Authenticated requests are not supported by it
- 3Pass headers or use
authin the options object
Show the answer
Correct answer: Pass headers or use auth in the options object
Explanation
cy.request({ url, headers: { Authorization: 'Bearer ...' } }). It also sends the browser's cookies for that domain.