I want to get a list of strings using `localStorage` as pesented by:

```
this.userService.getExpertisesListByIdUser(2).map((listExpertises: Array<any>) =>
      {
          let result:Array<Expertise> = [];
          let libs:Array<String> = [];
          if (listExpertises)
          {
              listExpertises.forEach((expert) =>
              {
                  libs.push(expert.name);
                  result.push(new Expertise(expert.id, expert.name, expert.username));
              });
          }

          localStorage.removeItem("libs");
          localStorage.setItem("libs", JSON.stringify(libs));

      })

      var storedNames = JSON.parse(localStorage.getItem("libs"));
      console.log(storedNames.length);   // That gives 0 as length : WRONG

```

the method **getExpertisesListByIdUser** is:

```
getExpertisesListByIdUser(id: number): Observable<any>
{
    return this.http.get(`${this.baseUrl}/users/expertises/${id}`);
}

```

As commented I got the length as 0.
I got the correct result if I put `localStorage` outside `map`.
But, I need it inside `map` to get the **synchronization**.

Now, the size is correct whith this code.

```
this.userService.getExpertisesListByIdUser(2).subscribe(listExpertises => {

         let libs:Array<String> = [];
         let exps:Array<Expertise> = [];

         if (listExpertises)
         {
             listExpertises.forEach((expert) =>
             {
               libs.push(expert.name);
               exps.push(new Expertise(expert.id, expert.name, expert.selected));
             });
         }

         localStorage.removeItem("libs");
         localStorage.setItem("libs", JSON.stringify(libs));

         localStorage.removeItem("exps");
         localStorage.setItem("exps", JSON.stringify(exps));

      });

      var storedNames = JSON.parse(localStorage.getItem("libs"));
      var storedExperties = JSON.parse(localStorage.getItem("exps"));
      console.log("----------------- Size: " + storedNames.length);
      console.log(storedNames);

      storedNames.forEach((name: string) =>
      {
          console.log("--------------Name from list of strings: " + name);
      });

      storedExperties.forEach((exp: Expertise) =>
      {
          console.log("--------------Name from list of objects: " + exp.name);
      });

```

but on console I got:

[![screenshot of empty list](https://i.stack.imgur.com/hIHgA.png)](https://i.stack.imgur.com/hIHgA.png)

Could you please tell me what I missed ?.

Thanks in advance.