elastic / elastic/site-search-node
Upgrade APIs to return Javascript Promises.
- Dominant language
- JavaScript
- Stars
- 9
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Since async functions have been introduced to Javascript, I find it difficult to use libraries that resort to passing callback functions as arguments, as callbacks are an inferior syntax that cause stacking, and await introduces performance optimizations for Javascript engines.
I suggest if a callback function is not passed into any of the API calls, return a promise that resolve or rejects with the result. This way, the API is being expanded and doesn't introduce any breaking changes.
e.g.
```
async function runMySearch() {
try {
const res = await client.search({
engine: "my-engine",
q: "cats",
filters: {
page: {
enumField: "theFilter"
}
},
facets: {
page: ["enumField", "anotherField"]
}
});
console.log(res);
} catch(err) {
console.log(err);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.