Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70747

How to reinject data in a global provider

$
0
0

@kacreation wrote:

hi everybody,
my problem : i have a global provider where I want to inject all variables needed for my app.
and i have TWO others providers (network and webwservices )that need to interact with this global provider.
My NetWork Provider check some basics fonctionnality and get the uuid device, No problem to inject this data in my globalProvider. I’m using this data again in my Webservices provider wich is use to interact with my Api (get and update data). So I post this data to my Api and get a object response with a token.
I’d like to reinject this token in my global Provider but it doesn’t work.I walways get my dat undefine in my global Provider.
here is my code :
webservicesProvider.ts

return this.global.apiToken;this.http.post(this.url_api + '?action=getToken', dataToPost)
                .subscribe(data => {
                    console.log(data);
                    
                     console.log(data['status']); 
                    if (data['status']==1){
                        console.log(data['token']);
                        this.global.apiToken = data['token'];
                        
                        console.log(this.global.apiToken);
                    }else{
                        console.log('erreur status');
                    }    

and in my globalProvider.ts :

 /***********Token *********/
    public apiToken : string;
    public decryptToken : string;

i just made a console.log of my apiToken in the constructor and it returned Undefined.

Does somebody can help me ?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70747

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>