File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 8686 }
8787 },
8888 apiLookup() {
89- fetch('https://api.ror.org /v1 /organizations?affiliation = ' + this.searchPhrase + '*' )
89+ fetch('https://api.ror.org /v2 /organizations?query = ' + this.searchPhrase )
9090 .then (response = > response.json ())
9191 .then (data = > {
9292 this.organizations = [];
9393 let items = data.items ;
9494 items.forEach ((item) = > {
95- let labels = { /* */ };
96- for (let i = 0; i < item.organization.labels.length ; i++) {
97- labels[item.organization.labels [i].iso639 ]
98- = item.organization.labels [i].label
99- }
95+ let names = { /* */ };
96+ const noLangCode = 'no_lang_code';
97+ const displayLocale =
98+ item.names ?.find ((i) = > i.types.includes ('ror_display'))?.lang !== null
99+ ? item.names ?.find ((i) = > i.types.includes ('ror_display'))?.lang
100+ : noLangCode;
101+
102+ item.names ?.forEach ((name) = > {
103+ if (name.types.includes ('label') || name.types.includes ('ror_display')) {
104+ const locale = name.lang !== null ? name.lang : noLangCode;
105+ names[locale] = name.value ;
106+ }
107+ });
108+
100109 let row = {
101- id: item.organization. id ,
102- name: item .organization.name ,
103- labels: labels
110+ id: item.id ,
111+ name: names[displayLocale] ,
112+ labels: names
104113 };
105114
106115 this.organizations.push (row);
You can’t perform that action at this time.
0 commit comments