File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ export class HTTPClient {
4646 if ( options . headers [ "Content-Type" ] === 'application/json' ) {
4747 result = await response . json ( ) ;
4848 }
49- if ( options . headers [ "Content-Type" ] === 'text/plain' ) {
49+ if ( options . headers [ "Accept" ] === 'text/plain' ) {
50+ result = await response . text ( ) ;
51+ }
52+ if ( options . headers [ "Accept" ] === 'text/html' ) {
5053 result = await response . text ( ) ;
5154 }
5255 }
@@ -163,7 +166,23 @@ export class HTTPClient {
163166 const url = `libraries/${ this . currentLibrary } /entries/${ citationKey } ` ;
164167 const options = {
165168 method : "GET" ,
166- headers : { "Content-Type" : "text/plain" }
169+ headers : { "Accept" : "text/plain" }
170+ }
171+
172+ return this . #performRequest( url , options ) ;
173+ }
174+
175+ /**
176+ * Requests the preview for a certain BibEntry from the current library.
177+ * @param { string } citationKey - The citation key (identifier) of the entry.
178+ * @returns A string containing the preview with relevant information
179+ * about the entry (e.g. author, title, release date, etc.).
180+ */
181+ async getPreviewHTML ( citationKey ) {
182+ const url = `libraries/${ this . currentLibrary } /entries/${ citationKey } ` ;
183+ const options = {
184+ method : "GET" ,
185+ headers : { "Accept" : "text/html" }
167186 }
168187
169188 return this . #performRequest( url , options ) ;
You can’t perform that action at this time.
0 commit comments