@@ -104,27 +104,39 @@ export async function request({
104104 } ;
105105 const url_query = JSON . stringify ( vocabQuery ) ;
106106 const url_parameters = JSON . stringify ( attributes ) ;
107- const url_batch = JSON . stringify ( {
107+ const url_batch = pageSize ? JSON . stringify ( {
108108 page : page ,
109109 size : pageSize ,
110- } ) ;
110+ } ) : "" ;
111111
112- const url = encodeURI ( `${ vocabularyUrl } ${ vocabularyUrl . indexOf ( "?" ) !== - 1 ? "&" : "?" } query=${ url_query } &attributes=${ url_parameters } &batch=${ url_batch } ` ) ;
113- log . debug ( url ) ;
112+ let url = encodeURI ( `${ vocabularyUrl } ${ vocabularyUrl . indexOf ( "?" ) !== - 1 ? "&" : "?" } query=${ url_query } &attributes=${ url_parameters } ` + ( url_batch ? `&batch=${ url_batch } ` : "" ) ) ;
114113
115114 const headers = new Headers ( ) ;
116115 headers . set ( "Accept" , "application/json" ) ;
117116
118- const response = await fetch ( url , {
117+ let request_params = {
119118 method : method ,
120119 headers : headers ,
121- } ) ;
120+ } ;
121+
122+ if ( method == "POST" && url . indexOf ( "?" ) !== - 1 ) {
123+ const url_parts = url . split ( "?" ) ;
124+ url = url_parts [ 0 ] ;
125+ const post_data = url_parts [ 1 ] ;
126+ headers . set ( "Content-Type" , "application/x-www-form-urlencoded" ) ;
127+
128+ log . debug ( url , post_data ) ;
129+
130+ request_params [ 'body' ] = post_data ;
131+ }
132+
133+ const response = await fetch ( url , request_params ) ;
122134
123135 if ( ! response . ok ) {
124136 return {
125137 results : [ ] ,
126138 total : 0 ,
127- errors : json . errors ,
139+ errors : response . errors ,
128140 } ;
129141 }
130142
@@ -153,9 +165,13 @@ export async function get_items_from_uids(uids, config) {
153165 return [ ] ;
154166 }
155167 const selectedItemsFromUids = await request ( {
168+ // use POST request (when many selected items are present the URL might get too long)
169+ method : "POST" ,
156170 vocabularyUrl : config . vocabularyUrl ,
157171 attributes : config . attributes ,
158172 uids : uids ,
173+ // do not batch here, otherwise we do not get all items
174+ pageSize : null ,
159175 } ) ;
160176 let results = ( await selectedItemsFromUids ?. results ) || [ ] ;
161177 // resort the results based on the order of uids
0 commit comments