Skip to content

Commit

Permalink
Replace by react-native-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Loule95450 committed Feb 27, 2024
1 parent c4285f0 commit e6f5c75
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@react-navigation/native": "^6.1.12",
"react": "18.2.0",
"react-native": "^0.73.5",
"react-native-logs": "^5.1.0",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.29.0"
},
Expand Down
5 changes: 3 additions & 2 deletions src/service/apiCall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {logError} from '../utils/logger.ts';
import {logger} from 'react-native-logs';

const apiUrl = 'https://world.openfoodfacts.org/api/v2/product/';
const log = logger.createLogger();

export async function getProduct(barcode: string) {
interface ProductData {
Expand All @@ -26,7 +27,7 @@ export async function getProduct(barcode: string) {
data.categories = json.product.categories;
data.nutriments = json.product.nutriments;
} catch (error: any) {
logError(error);
log.error('Erreur lors de la récupération du produit', {error});
// Retourner un objet d'erreur spécifique
return {error: true, message: 'Erreur lors de la récupération du produit.'};
}
Expand Down
3 changes: 0 additions & 3 deletions src/utils/logger.ts

This file was deleted.

5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5823,6 +5823,11 @@ react-is@^17.0.1:
resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-native-logs@^5.1.0:
version "5.1.0"
resolved "https://registry.npmjs.org/react-native-logs/-/react-native-logs-5.1.0.tgz"
integrity sha512-bnTDoML/xH2V16ica6q4OJN7LIT0yz9mgeiAR1l3lvMTV6qfPGpiyy1G39mNfVorGIh3KbMLd6Av8dE2Pc33yA==

react-native-safe-area-context@^4.9.0, "react-native-safe-area-context@>= 3.0.0":
version "4.9.0"
resolved "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.9.0.tgz"
Expand Down

0 comments on commit e6f5c75

Please sign in to comment.