UNPKG

@lableb/javascript-sdk

Version:

Lableb cloud search client for javascript

39 lines (21 loc) 1.3 kB
// import * as LablebClient from '../../dist/LablebSDK.min.js'; // you can use the esm import syntax too, but don't forget to remove the import script tag for the library const sdkOptions = { platformName: 'js-sdk-test', APIKey: 'ymONe8448842-Y00sS2cLp-sAtosW25S7IhSi', }; window.addEventListener('DOMContentLoaded', async function onLoad(event) { const client = await window.LablebSDK.LablebClient(sdkOptions); const searchInput = document.getElementById('search-input'); const searchResultsContainer = document.getElementById('search-results'); const autocompleteResultsContainer = document.getElementById('autocomplete-results'); searchInput.addEventListener('keyup', async function onSearchInputChange(event) { const searchResponse = await client.search({ query: this.value }); const searchResults = searchResponse.response.results; searchResultsContainer.innerHTML = JSON.stringify({ searchResults }, undefined, 2) ////////////// const autocompleteResponse = await client.autocomplete({ query: this.value }); const autocompleteResults = autocompleteResponse.response.results; autocompleteResultsContainer.innerHTML = JSON.stringify({ autocompleteResults }, undefined, 2) }); });