This is a follow up to a question someone else had asked here How do I return the response from a cy.request through a function
I want to make a function which calls an api, processes the response and returns only a portion of the response. I have the below code which codes not work. I get the compiler error - a function whose type is neither undefined, void or null should return a value. How do I make this work?
Add(someName) : ItemClass {
cy.request({
method: 'POST',
url: someURL,
body: {
name: someName
}
}).then(function(response) {
let result = response.body.find((item) => {return item.id === 123})
return result; // result is of type ItemClass
})
}