https://cypress.io logo
Hello beautiful people. Im having some small deci...
# help
g
Hello beautiful people. Im having some small decision issue as I dont know if I should turn my function into a "pageobject", command nor task? I have a code that does a requests with some signatures to make the requests.
Copy code
ts
const requestUrl = `${constants.baseUrl.api}/hello/world/User/${userID}`.trim();
const pathToSign = Helper.getPathToSign(requestUrl);
const timeStamp = Helper.formatDateISOBasic(new Date());

const headers = [
  { name: 'override', value: 'yes' },
  { name: 'keylord', value: '12345' },
  { name: 'environment', value: 'thrill' },
  { name: 'timestamp', value: timeStamp },
];

const headerArray = {};
Object.entries(headers).forEach(([, header]) => { headerArray[header.name] = header.value; });

const signer = new MessageSigner();
const signature = signer.getSignature('barrythrill', pathToSign, headers, []);

cy.request({
  url: requestUrl,
  method: 'GET',
  headers: {
    ...headerArray,
    'signature': signature,
  },
  failOnStatusCode: false,
  log: true,
})
  .then((response) => {
    cy.log('resp', JSON.stringify(response));
  });
});
and I would like to get the response to do some except tests. I wonder where should I put such a code as? Function in pageobject, command or ...?