Hi,
I’m trying to get started with a creating a simple provider. What I’m currently struggling is to use multiple functions in my provider.
I created a provider named price
with the following command: ionic generate provider
.
Inside my provider, I created a function named getPrice
, but instead of just returning a value, it asks another function, which pulls the value from native storage. So inside my page.ts, I have this:
getPrice(currency)
{
this.myProvider.getPrice(currency).then((price) => {
this.price = price;
});
}
and my provider, looks like this:
getPrice(currency)
{
return new Promise((price, reject) => {
anotherFunction(currency);
});
}
anotherFunction(currency)
{
this.nativestorage.getItem('price').then(
data => {
this.price = data;
});
}
So as you can see, anotherFunction has the price, which needs to be returned to my page. How can I make the first function in my provider (getPrice) to return anotherFunction’s data?
Hope it was clear enough. Quite late in the day here.
Thanks ahead for any help