algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

Deno Support

Open takmatsukawa opened this issue 3 years ago • 2 comments

Are there any plans for supporting Deno runtime?

It's already possible to import algoliasearch via esm.sh and skypack, however it seems that using XMLHttpRequest makes it impossible.

Thanks!

takmatsukawa avatar Apr 28 '22 23:04 takmatsukawa

We have not had any requests in the past for Deno support, so have not yet looked into any quick wins. There's a couple options I see:

  1. polyfill XHR: https://deno.land/x/[email protected]
  2. pass a custom requester when creating the algoliasearch client, which uses fetch

I'd love to hear when you try these options out

Haroenv avatar Apr 29 '22 07:04 Haroenv

Thank you for your quick response! Maybe the second option is better but the first one worked!

import algoliasearch from 'https://esm.sh/[email protected]';
import "https://deno.land/x/[email protected]/mod.ts";

const client = algoliasearch(APP_ID, API_KEY);
const index = client.initIndex('my_index');

index.saveObject(object);

takmatsukawa avatar Apr 29 '22 11:04 takmatsukawa