Ionic 3 to fetch user data based on id

#1

I have two api’s one for login and another for user profile. I want to fetch data from user profile api based on the userid that i get from login api after login that i have stored in a localStorage. Now how do i pass this userid as parameter to fetch data from user profile api. Any idea?

#2

You can take an array like let data { uid =this.uid} and then pass it with your api like(’ http://…’ data).

#3

After login i am writting this code:
const data = JSON.parse(localStorage.getItem(‘user’));
console.log(data);

Getting output:
{userid: “1”, status: “true”, message: “Login Success”}

Now how do i use the userid to fetch data from user profile api.

#4

this.localStorage.getItem(‘user’)
.then((data) => {
if (data != null) {
let fd = new FormData();
fd.append(‘user’, data);
this.Http.get"yourapi"(fd)
.then((response) => {
this.data = response;

#5

I am using the code in app.component.ts but getting error:
this.localStorage.getItem(‘user’).then((data)=>{
if(data!=null){
let fd=new FormData();
let x=fd.append(‘user’,data);
console.log(“test”,x);
}else{
console.log(“Check your code”);
}
});

Error: Property ‘localStorage’ does not exist on type ‘MyApp’

In console it prints: Check your code