ere is an example:
import { Component } from '@angular/core';
import { Storage } from '@capacitor/storage';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
html = 'hello';
constructor(public http: HttpClient) {}
async test() {
await this.saveToStorage();
this.problem();
}
async saveToStorage() {
console.log('Saving something to local storage...');
await Storage.set({
key: 'url',
value: 'https://jsonplaceholder.typicode.com/posts',
});
}
problem() {
this.getApiValue().then((value) => {
this.html = JSON.stringify(value) ;
});
}
async getApiValue() {
const urltogo = await Storage.get({key:'url'});
return this.http.get(urltogo.value).toPromise();
}
}