Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't pass country code if it's null #324

Merged
merged 11 commits into from Dec 16, 2021
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