Skip to content

Commit e652f84

Browse files
Merge pull request #2 from FitzwilliamMuseum/jn-fix-undefined-micrograph-annotation
fix error on undefined micrograph annotation
2 parents f1a9e83 + c07ca3f commit e652f84

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

directus.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export async function fetchMicrographAll() {
2020
}
2121

2222
export async function fetchMicrograph(id) {
23-
const response = await fetch(apiBase + "items/micrographs/" + id);
23+
const url = apiBase + "items/micrographs/" + id;
24+
console.log("fetchMicrograph url", url);
25+
const response = await fetch(url);
2426
return (await response.json()).data;
2527
}
2628

@@ -42,6 +44,8 @@ export async function downloadImage(id, outputFilePath, imageOptions) {
4244
}
4345

4446
export async function fetchFileObject(id) {
45-
const response = await fetch(apiBase + "files/" + id);
47+
const url = apiBase + "files/" + id;
48+
console.log("fetchFileObject url",url);
49+
const response = await fetch(url);
4650
return (await response.json()).data;
4751
}

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,11 @@ async function main() {
216216

217217
const micrographId = data[fieldMap.annotation.key][j];
218218

219+
console.log("micrograph index", j);
220+
console.log("micrographId", micrographId);
219221
const currentItem = await fetchMicrograph(micrographId);
220-
if (!currentItem || !currentItem.hotspot) continue
221-
console.log("micrograph", j);
222+
if (!currentItem || !currentItem.hotspot || !currentItem.micrograph) continue
223+
console.log("micrograph hotspot", true);
222224

223225
const annotationItemId = basePath + path.join("annotation/tag/", currentItem.id.toString());
224226
const targetCoords = `${currentItem[fieldMap.annotation.x]},${currentItem[fieldMap.annotation.y]},${currentItem[fieldMap.annotation.w]},${currentItem[fieldMap.annotation.h]}`;

0 commit comments

Comments
 (0)