Hello people! How do I return a `.then` response o...
# e2e-testing
g
Hello people! How do I return a
.then
response of something like this:
Copy code
ts
import MessageSignerHelper from '../plugins/sales/MessageSignerHelper';

/**
 * Sub page containing specific selectors and methods for a specific page
 *
 * @class
 */

class BarryApi{
  static itemLists(requestUrl: string): any {
    let itemList;

    const signatureHeaders = [
      { name: 'override', value: 'hello_world' },
    ];

    cy.task('Signature', { pathToSign, headers: signatureHeaders }).then((signature) => {
      cy.request({
        url: requestUrl,
        method: 'GET',
        headers: {
          'signature': signature,
        },
        failOnStatusCode: false,
        log: true,
      })
        .then((response) => {
          itemList = JSON.stringify(response.body);
        });
    });
    return itemList ;
  }
}

export default BarryApi;
When I call BarryApi.itemLists('https://barrythrill.com') it returns undefined but if I add a console.log inside the
.then((response)
then I can see the values so my question is how can I get the return value by doing something like
Copy code
ts
let testing;
testing = BarryApi.itemLists('https://barrythrill.com');
console.log(testing);
?