Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(http): replace HttpModule with HttpClientModule #520

Merged
merged 1 commit into from
Oct 22, 2017

Conversation

krjordan
Copy link
Contributor

No description provided.


searchBooks(queryTitle: string): Observable<Book[]> {
return this.http
.get(`${this.API_PATH}?q=${queryTitle}`)
.map(res => res.json().items || []);
.get<Book[]>(`${this.API_PATH}?q=${queryTitle}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response is an object that contains items, which is an array of books. Pass that as the type

.get<{ items: Book[] }>

Then you won't have to type books as any, because items will be inferred as Book[] and just use res => res.items || []

@krjordan krjordan force-pushed the refactor/http-to-use-httpClient branch from 3466500 to 5f8515e Compare October 22, 2017 19:42
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.54% when pulling 5f8515e on refactor/http-to-use-httpClient into 7927f8e on master.

@brandonroberts brandonroberts merged commit f56fb54 into master Oct 22, 2017
@brandonroberts brandonroberts deleted the refactor/http-to-use-httpClient branch October 22, 2017 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants