Tegar D Pratama
Tegar D Pratama

Reputation: 167

How to use Ionic Storage to store json object from api with ionic 3?

I would like to know how to use Ionic Storage to store Json Object with Ionic 3. I am finding it difficult as there are no examples for the ionic 3 and i am stuck. Nothing on the net seems to be updated. A supporting example for Ionic Storage would be of great use. Thank you in advance.

Upvotes: 1

Views: 12949

Answers (1)

Sampath
Sampath

Reputation: 65860

Yes, you can store JSON objects in Ionic storage.

  let your_json_object = { "name":"John", "age":30, "car":null };

  // set a key/value
  storage.set('my-json', your_json_object);

  // to get a key/value pair
  storage.get('my-json').then((val) => {
    console.log('Your json is', val);
  });

Upvotes: 11

Related Questions