This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
75 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpParams } from '@angular/common/http'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { environment } from '../../environments/environment'; | ||
import { ParseResult } from '../_models/parse-result'; | ||
import { ParseResults } from '../_models/parse-result'; | ||
|
||
export class ParseRequest { | ||
constructor( | ||
public ingredients?: string[], | ||
) {} | ||
} | ||
|
||
@Injectable() | ||
export class ParserService { | ||
|
||
constructor(private http:HttpClient) { } | ||
|
||
public parseIngredient(ingredientRaw: string) : Observable<ParseResult> { | ||
return this.http.get<ParseResult>(`${environment.backendBaseUrl}/v1/parse`, { | ||
params: new HttpParams().set('q', ingredientRaw), | ||
}); | ||
public parseIngredients(request: ParseRequest) : Observable<ParseResults> { | ||
|
||
const httpOptions = { | ||
headers: new HttpHeaders({ | ||
'Content-Type': 'application/json', | ||
}), | ||
}; | ||
return this.http.post<ParseResults>( | ||
`${environment.backendBaseUrl}/parseIngredients`, request, httpOptions); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters