2017-09-19 04:28:26 +02:00
|
|
|
require('es6-promise').polyfill();
|
|
|
|
require('isomorphic-fetch');
|
|
|
|
|
|
|
|
/**
|
2017-09-22 03:05:48 +02:00
|
|
|
* TODO: Handle country/locale
|
2017-09-19 04:28:26 +02:00
|
|
|
*/
|
|
|
|
export default function (EAN) {
|
|
|
|
return fetch(
|
|
|
|
`https://world.openfoodfacts.org/api/v0/product/${EAN}.json`,
|
|
|
|
)
|
|
|
|
.then(response => response.json())
|
|
|
|
.catch(exc => console.error(`Unable to fetch product: ${exc}.`));
|
|
|
|
}
|