Skip to content

Commit

Permalink
parseCompletions handles v3 api result
Browse files Browse the repository at this point in the history
v2 api returns a ResultSet: { Result: { Name: xxx } } but the v3 api returns result: [ xxx ] so map the latter to the former.
  • Loading branch information
howff committed Nov 19, 2019
1 parent f2cea08 commit 5d8dcdc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckan/public/base/javascript/client.js
Expand Up @@ -160,6 +160,9 @@
}

var map = {};
// If given a 'result' array then convert it into a Result dict inside a Result dict.
data = data.result ? { 'ResultSet': { 'Result': data.result.map(x => ({'Name': x})) } } : data;
// If given a Result dict inside a ResultSet dict then use the Result dict.
var raw = jQuery.isArray(data) ? data : data.ResultSet && data.ResultSet.Result || {};

var items = jQuery.map(raw, function (item) {
Expand Down

0 comments on commit 5d8dcdc

Please sign in to comment.