Skip to content

Commit

Permalink
Merge pull request #6 from afosto/Feature/update-search-endpoint-to-n…
Browse files Browse the repository at this point in the history
…ew-api

Feature/update-search-endpoint-to-new-api
  • Loading branch information
Rapid0o authored Jan 25, 2022
2 parents 01dd6ae + ae33522 commit ca68ae4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
This library is an Afosto search client plugin for the open-source <a href="https://github.com/algolia/instantsearch.js">InstantSearch.js</a> library (powered by Algolia). With this plugin you can use the amazing widgets of the InstantSearch.js library, while communicating with the Afosto search API.
</p>

## 🚧 Currently in development 🚧

## Installation

### Basic
Expand Down Expand Up @@ -114,7 +112,7 @@ For more information check the React InstantSearch [documentation](https://www.a
## Compatibility

- InstantSearch.js v4
- Node >= 12.10
- Node >= 14

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@afosto/instant-search-client",
"version": "0.3.3",
"version": "1.0.0",
"private": false,
"description": "The Afosto InstantSearch client",
"main": "./dist/afosto-instant-search.min.js",
Expand Down
26 changes: 15 additions & 11 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
<h2>Brands</h2>
<div id="brand-list"></div>

<h2>Color</h2>
<div id="color-list"></div>
<h2>Supplier</h2>
<div id="supplier-list"></div>

<h2>Price</h2>
<h2>Length</h2>
<div id="range-slider"></div>
</div>
<div style="flex:1;padding:20px">
Expand Down Expand Up @@ -80,25 +80,25 @@ <h2>Products</h2>

instantsearch.widgets.refinementList({
container: '#brand-list',
attribute: 'merk',
attribute: 'Brand',
operator: 'and',
searchable: false,
showMore: true,
showMoreLimit: 500,
}),

instantsearch.widgets.refinementList({
container: '#color-list',
attribute: 'kleur',
container: '#supplier-list',
attribute: 'Supplier',
operator: 'and',
searchable: true,
searchable: false,
showMore: true,
showMoreLimit: 500,
}),

instantsearch.widgets.rangeSlider({
container: '#range-slider',
attribute: 'price',
attribute: 'Length',
precision: 0,
step: 1,
}),
Expand Down Expand Up @@ -126,11 +126,15 @@ <h2>Products</h2>
<div class="ais-Hits-list-item">
<img src="{{metadata.image}}" align="left" alt="{{metadata.name}}" width="100" />
<div class="hit-name">
{{metadata.name}}
{{title}}
</div>
<div class="hit-release-date">Brand: {{metadata.brand}}</div>
<div class="hit-release-date">Brand: {{Brand}}</div>
<div class="hit-release-date">Length: {{Length}}</div>
<div class="hit-description">
&euro;{{metadata.price}}
{{description}}
</div>
<div class="price">
&euro;{{price}}
</div>
</div>
`,
Expand Down
2 changes: 1 addition & 1 deletion src/afostoInstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const afostoInstantSearch = (proxyId, options) => {
Accept: 'application/vnd.instantsearch+json',
...(requestOptions.headers || {}),
},
body: JSON.stringify(payload),
body: JSON.stringify({ data: payload }),
});
const response = await searchResponse.json();

Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const DEFAULT_OPTIONS = {
allowEmptyQuery: true,
baseUrl: 'https://api.afosto.io/cnt/instant/search/{proxyId}',
baseUrl: 'https://afosto.io/api/instant/search/{proxyId}',
hitsPerPage: 10,
requestOptions: {},
threshold: 1,
Expand Down

0 comments on commit ca68ae4

Please sign in to comment.