Skip to content

Commit

Permalink
fix: Don't pass country code if it's null (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmeet0817 committed Dec 16, 2021
1 parent d67fe48 commit 5f9447c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/openfoodfacts.dart
Expand Up @@ -871,14 +871,18 @@ class OpenFoodAPIClient {
) async {
const String KNOWLEDGE_PANELS_FIELD = 'knowledge_panels';

var queryParameters = <String, String>{
'fields': KNOWLEDGE_PANELS_FIELD,
'lc': configuration.language!.code,
};
String? cc = configuration.computeCountryCode();
if (cc != null) {
queryParameters.putIfAbsent('cc', () => cc);
}
var uri = UriHelper.getUri(
path: 'api/v2/product/${configuration.barcode}/',
queryType: queryType,
queryParameters: <String, String>{
'fields': KNOWLEDGE_PANELS_FIELD,
'lc': configuration.language!.code,
'cc': configuration.computeCountryCode()!,
},
queryParameters: queryParameters,
);

try {
Expand Down

0 comments on commit 5f9447c

Please sign in to comment.