Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49253

Help with Ionic Storage

$
0
0

@emrade wrote:

Hello guys, please i need help with ionic storage. I have a few questions

  1. When i save data to storage should i stringify it first if it is an array?

  2. I have a service which perform my crud operations for me. I want to return the data saved in my storage through a service to my home page but i get an error which says void is not assignable to type Promise<Todo>

Below is some codes from my service page for more clarification

 private todos: Todo[] = [];

getAllTodos(){
    this.storage.get(STORAGE_KEY).then((result) => {
      this.todos = result == null ? [] : result;
  	return [...this.todos];
    });
  }
  1. On my home page, i have a code that looks like
private todos: Promise<Todo[]>;
  private todo: Todo;

  ionViewWillEnter(){
    this.todos = this.getAllTodo(); //This is the line that says  void is not assignable to type Promise<Todo>
  }

getAllTodo(){
    return this.todoService.getAllTodos();
  }

Please i’d appreciate it so much if anyone is able to help me understand this concept.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49253

Trending Articles