Skip to content

Instantly share code, notes, and snippets.

@ganqqwerty
Last active September 25, 2019 14:48
Show Gist options
  • Save ganqqwerty/316775e6420cae4e1d8ca1f044105e22 to your computer and use it in GitHub Desktop.
Save ganqqwerty/316775e6420cae4e1d8ca1f044105e22 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient, HttpParams } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class ProductService {
private readonly URL = 'https://world.openfoodfacts.org/api/v0/product/';
constructor(private http: HttpClient) {
}
resolveProduct(code: string): Observable<any> {
console.log('Request is sent!')
return this.http.get(this.URL+code+'.json');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment