Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angularjs How to get Capacitor Storage values before doing http call IONIC 6

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();
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: binance client create order 
Javascript :: shopify bypass cart 
Javascript :: how to push array 
Javascript :: map js 
Javascript :: jquery autocomplete search 
Javascript :: angular form validation whitespace 
Javascript :: last index of array js 
Javascript :: mongoose auto increment 
Javascript :: hot to set file views in nodejs 
Javascript :: numeros que mais se repetem em um array 
Javascript :: redireccionar a una página con javascript después de un tiempo 
Javascript :: jquery slider get value on change 
Javascript :: text animation css and js 
Javascript :: async function javascript dec 
Javascript :: bootstrap 4 form validator with jquery 
Javascript :: array.findindex is not a function 
Javascript :: check javascript object not array and not null 
Javascript :: e editable select no button 
Javascript :: chrome extension inject html 
Javascript :: .includes javascript 
Javascript :: create a drop down to select time javascript 
Javascript :: competitive programming in javascript 
Javascript :: angular remove element from array 
Javascript :: react native uid 
Javascript :: disable livewire error model 
Javascript :: js confirm 
Javascript :: javascript prototype example 
Javascript :: how sum all array element with while loop 
Javascript :: nested arrays javascript 
Javascript :: yup.array not working 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =