From e55e0109103d587898b19f08a43f918b0d38d439 Mon Sep 17 00:00:00 2001 From: An Tran Date: Tue, 14 May 2024 17:45:17 +0700 Subject: [PATCH] chore: add node-fetch --- package-lock.json | 1 + package.json | 1 + scripts/orama-search/sync-orama-cloud.mjs | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cfecfa93ebcca..d06892f0d5496 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,7 @@ "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "jest-junit": "16.0.0", + "node-fetch": "^2.7.0", "prettier": "3.2.5", "prettier-plugin-tailwindcss": "0.5.14", "remark-frontmatter": "5.0.0", diff --git a/package.json b/package.json index 25eab135e6502..16776f46dfd0f 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "jest-junit": "16.0.0", + "node-fetch": "^2.7.0", "prettier": "3.2.5", "prettier-plugin-tailwindcss": "0.5.14", "remark-frontmatter": "5.0.0", diff --git a/scripts/orama-search/sync-orama-cloud.mjs b/scripts/orama-search/sync-orama-cloud.mjs index 66d258a5419a2..21a95668210df 100644 --- a/scripts/orama-search/sync-orama-cloud.mjs +++ b/scripts/orama-search/sync-orama-cloud.mjs @@ -1,5 +1,6 @@ import { siteContent } from './get-documents.mjs'; import { ORAMA_SYNC_BATCH_SIZE } from '../../next.constants.mjs'; +import fetch from 'node-fetch'; // The following follows the instructions at https://docs.oramasearch.com/cloud/data-sources/custom-integrations/webhooks @@ -35,19 +36,18 @@ const insertBatch = async batch => { headers: oramaHeaders, body: JSON.stringify({ upsert: batch }), }); -} +}; // We call the "deploy" API to trigger a deployment of the index, which will process all the documents in the queue. // Full docs on the "deploy" API: https://docs.oramasearch.com/cloud/data-sources/custom-integrations/webhooks#deploying-the-index const triggerDeployment = async () => { - await fetch(`${ORAMA_API_BASE_URL}/deploy`, { method: 'POST', headers: oramaHeaders, }); console.log('Deploy done'); -} +}; // We call the "snapshot" API to empty the index before inserting the new documents. // The "snapshot" API is typically used to replace the entire index with a fresh set of documents, but we use it here to empty the index.