Hello guys, please i need help with ionic storage. I have a few questions
-
When i save data to storage should i stringify it first if it is an array?
-
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];
});
}
- 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.