https://cypress.io logo
Cypress.SelectorPlayground crashes on cy.request()
# i-need-help
c
Hi I am sending an API request by
cy.request()
with the following syntax:
Copy code
cy.request(
    {
      method: method,
      url: format(endpoint, option),
      failOnStatusCode: false,
      headers: headers,
      body: normalisedRequest
    })
It works when the
body
is an object or string, but when the body is a number, the test fails and selector playground crashes. The error is
Copy code
The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (1)
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (1)
    at new NodeError (node:internal/errors:372:5)
    at write_ (node:_http_outgoing:742:11)
    at ClientRequest.write (node:_http_outgoing:707:15)
    at ee.write (<embedded>:1955:83025)
Please help. I need to use only a number as request body. Thanks