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
:: lunix increae ram available to nodejs 
Javascript :: js code to accept all linkedin requests 
Javascript ::  
::  
:: querySelectorAll multiple lists 
:: multiselect 
Javascript ::  
::  
Javascript :: 15) Which of the following directive is used to initialize an angular app? A. ng-app ANSWER B.ng-model C.ng-controller D.None of the above 
Javascript ::  
:: node js rate limiter fastify 
Javascript :: Replacing String Content 
Javascript ::  
:: npm install say unmet dependencies 
:: acer swift 5 
Javascript :: supertest formdata 
Javascript ::  
::  
::  
::  
Javascript ::  
Javascript ::  
Javascript :: how to alert in javascript 
Javascript :: supertest expect content type 
:: ask for expo token and save to firebase 
:: how to use react memo hooks 
Javascript :: how to give index in query selector in js 
::  
Javascript :: duplicate images in webpage js 
::  
ADD CONTENT
Topic
Content
Source link
Name
6+1 =