getToken() {
let res={};
let token = this.cookiesServices.getCookie("mobilecookie");
if(token){
res.token=token;
console.log("token-res",res);
return res;
}else{
return new this.httpUtils.POST(`${this.apiUrl2}authorization/token`);
}
getStoresCategories(mallId) { const res = this.getToken();
const defferd = this.$q.defer();
return res.then(dta => {
const { token } = dta;
const url = `${this.apiUrl2}stores/mall/${mallId}`;
const conf = {
headers: {
Authorization: `bearer ${token}`,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
}
};
this.$http.get(url, conf).then(rsp => {
defferd.resolve(rsp.data.data);
});
return defferd.promise;
});
}
cache error TypeError: res.then is not a function
The problem is that res
is not a Promise, you should use $q.resolve
to transform it into a Promise