I am facing a TypeScript dilemma. I have a REST method that is being called within my http library by Vue action. I want the resolve() method to return the typed array, but if I do not convert it within the action.ts "then" method, I get a '.length does not exist in type {}' error.
Is there a way to avoid recasting the result to my typed array since it was already done in the http.ts method?
http.ts (partial)
getapps() {
return new Promise((resolve, reject) => {
this.axios.post('/account/getapps').then((response) => {
resolve(response.data as DomainAppType[]);
}, (err) => {
reject(err);
});
});
}
action.ts
import { DomainAppType } from '../models/domainApps';
var actions = {
LOGIN: function ({ commit }, params) {
http.getapps(params.email, params.password).then(apps => {
var appList = <DomainAppType[]>apps;
console.log(appList.length);
}).catch((err) => {
console.log(JSON.stringify(err));
})
}
}
export default actions