It’s easy but I keep forgetting. I have a function that triggers an axios request and returns it as a promise – unless the value is already there. In that case I want to return a simple promise with just the value. The solution is Promise.resolve
async getSomeData(){
if(this.dataStored !== null) {
return Promise.resolve(this.dataStored);
}
return axios.get('/api/someurl')
.then(response => {
this.dataStored = response.data;
return response.data;
});
}