Local API: Use getByLibraryAndKeyAsync()
This commit is contained in:
parent
3f45def928
commit
3231e24bd5
1 changed files with 4 additions and 4 deletions
|
@ -708,8 +708,8 @@ Zotero.Server.Endpoints["/api/groups/:groupID/searches/:searchKey/items"] = Zote
|
||||||
Zotero.Server.LocalAPI.Item = class extends LocalAPIEndpoint {
|
Zotero.Server.LocalAPI.Item = class extends LocalAPIEndpoint {
|
||||||
supportedMethods = ['GET'];
|
supportedMethods = ['GET'];
|
||||||
|
|
||||||
run({ pathParams, libraryID }) {
|
async run({ pathParams, libraryID }) {
|
||||||
let item = Zotero.Items.getByLibraryAndKey(libraryID, pathParams.itemKey);
|
let item = await Zotero.Items.getByLibraryAndKeyAsync(libraryID, pathParams.itemKey);
|
||||||
if (!item) return _404;
|
if (!item) return _404;
|
||||||
return { data: item };
|
return { data: item };
|
||||||
}
|
}
|
||||||
|
@ -721,8 +721,8 @@ Zotero.Server.Endpoints["/api/groups/:groupID/items/:itemKey"] = Zotero.Server.L
|
||||||
Zotero.Server.LocalAPI.ItemFile = class extends LocalAPIEndpoint {
|
Zotero.Server.LocalAPI.ItemFile = class extends LocalAPIEndpoint {
|
||||||
supportedMethods = ['GET'];
|
supportedMethods = ['GET'];
|
||||||
|
|
||||||
run({ pathname, pathParams, libraryID }) {
|
async run({ pathname, pathParams, libraryID }) {
|
||||||
let item = Zotero.Items.getByLibraryAndKey(libraryID, pathParams.itemKey);
|
let item = await Zotero.Items.getByLibraryAndKeyAsync(libraryID, pathParams.itemKey);
|
||||||
if (!item) return _404;
|
if (!item) return _404;
|
||||||
if (!item.isFileAttachment()) {
|
if (!item.isFileAttachment()) {
|
||||||
return [400, 'text/plain', `Not a file attachment: ${item.key}`];
|
return [400, 'text/plain', `Not a file attachment: ${item.key}`];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue