diff --git a/templates/javascript/onboarding/method.mustache b/templates/javascript/onboarding/method.mustache new file mode 100644 index 00000000000..b1373072281 --- /dev/null +++ b/templates/javascript/onboarding/method.mustache @@ -0,0 +1,15 @@ +import { algoliasearch } from 'algoliasearch'; + +// Connect and authenticate with your Algolia app +const client = algoliasearch('YourApplicationID', 'YourWriteAPIKey'); + +// Fetch and index objects in Algolia +const processRecords = async () => { + const datasetRequest = await fetch('https://dashboard.algolia.com/sample_datasets/movie.json'); + const objects = await datasetRequest.json(); + // return client.saveObjects({ indexName: 'movies_index', objects }); +}; + +processRecords() + .then(() => console.log('Successfully indexed objects!')) + .catch((err) => console.error(err)); \ No newline at end of file