javascript - How do I return list/value from ionic2/3 storage -


i know isn't 100% right way this, advice cleanup welcome.

just learning/getting used ionic2 , i'm having trouble returning storage item.

service:

import { injectable } "@angular/core"; import { storage } '@ionic/storage';  @injectable() export class locationitemservice {   locationitems: locationitem[] = [];    constructor(     private storage: storage   ) {}    getlistitems(id): promise<locationitem[]> {     this.storage.get("location_items_" + id).then((val) => {       // console out proper value.       console.log(val);       // promise contains proper value.       return promise.resolve(val);     });   } } 

however, when run application in development, error: "a function declared type neither 'void' nor 'any' must return value."

even if set this.locationitems, still need return promise next function not run until promise resolved.

i figured had scope being inside of storage.get, instead of directly within function itself, , have tried few workarounds no avail. thank whatever input may have!

oi, not using return before this.storage. defined promise. , return statements stuck in limbo.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -