The results.session_id has a red squiggly on it because it is an unknown parameter. How do I let Angular/TS that it is a valid parameter?

```
this.requestManager.loginRequest(email, password).subscribe(
  result => {
    localStorage.setItem('session_id', result.session_id)
    this.router.navigate(['/discover'])
  },
  error => {},
  () => {}
)

1 Answers

2
Alexander Staroselsky On Best Solutions

You can use bracket notation to access the property:

this.requestManager.loginRequest(email, password).subscribe(
  result => {
    localStorage.setItem('session_id', result['session_id'])
    this.router.navigate(['/discover'])
  },
  error => {},
  () => {}
)

Otherwise the better option could be creating an interface to represent the “result” and use HttpClient get() with a type in your service:

interface Session {
  session_id: string;
}

this.http.get<Session>(“some-url”);

Hopefully that helps!