gentle-accountant-4760
09/30/2022, 12:24 PM.then
response of something like this:
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
ts
let testing;
testing = BarryApi.itemLists('https://barrythrill.com');
console.log(testing);
?