Expected 1 arguments when using storage in ionic

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Expected 1 arguments when using storage in ionic



I tried using local storage in my ionic service provider app but I got this error.



[ts] Expected 1 arguments, but got 0. (alias) new Storage(config:
StorageConfig): Storage import Storage Create a new Storage instance
using the order of drivers and any additional config options to pass
to LocalForage.



Possible driver options are: ['sqlite', 'indexeddb', 'websql',
'localstorage'] and the default is that exact ordering.



Here is my source code:


import Storage from '@ionic/storage';

@Injectable()
export class MyServiceProvider
public local : Storage;
mydata: any;


constructor(public http: Http)
this.local = new Storage()


postLogin(data)
let link = "http://myapi.com/api/login.php";
return this.http.post(link, data)
.map(data =>
this.mydata = data;
console.log("data")
, error =>
console.log(error)
)






1 Answer
1



I didn't understand well what you want to do with the Storage, but according to Ionic Storage docs, you need to inject into your provider/component.


import Storage from '@ionic/storage';

export class MyApp
constructor(private storage: Storage)



I suggest you to use that provider do get and set the data and you can call these methods wherever you import your provider.


public setData(nameData: string, valueData: any)
this.storage.set(nameData, valueData);


public getDataValue(nameData: string)
return this.storage.get(nameData);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard