Skip to content

Commit 29fa94e

Browse files
authored
Update 1.vue-instantsearch.md
1 parent f6e1135 commit 29fa94e

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

docs/content/2.advanced/1.vue-instantsearch.md

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,42 @@ onBeforeMount(() => {
8080
})
8181

8282
const { data: algoliaState } = await useAsyncData('algolia-state', async () => {
83-
return instantsearch.findResultsState({
84-
// IMPORTANT: a component with access to `this.instantsearch` to be used by the createServerRootMixin code
85-
component: {
86-
$options: {
87-
components: { AisInstantSearchSsr, AisRefinementList, AisSortBy },
88-
data() {
89-
return { instantsearch }
90-
},
91-
provide: { $_ais_ssrInstantSearchInstance: instantsearch },
92-
render() {
93-
return h(AisInstantSearchSsr, null, () => [
94-
// Include any vue-instantsearch components that you use including each refinement attribute
95-
h(AisRefinementList, { attribute: 'languages' }),
96-
h(AisSortBy, { items: [{ value: indexName, label: '' }] }),
97-
])
83+
if (process.server) {
84+
const nuxtApp = useNuxtApp();
85+
nuxtApp.$algolia.transporter.requester = (
86+
await import('@algolia/requester-node-http').then(
87+
(lib) => lib.default || lib
88+
)
89+
).createNodeHttpRequester();
90+
}
91+
return instantsearch.findResultsState({
92+
// IMPORTANT: a component with access to `this.instantsearch` to be used by the createServerRootMixin code
93+
component: {
94+
$options: {
95+
components: {
96+
AisInstantSearchSsr,
97+
AisIndex,
98+
AisConfigure,
99+
AisRefinementList,
100+
AisHits,
101+
AisHighlight,
102+
AisSearchBox,
103+
AisStats,
104+
AisPagination,
105+
},
106+
data() {
107+
return { instantsearch };
108+
},
109+
provide: { $_ais_ssrInstantSearchInstance: instantsearch },
110+
render() {
111+
return h(AisInstantSearchSsr, null, () => [
112+
// Include any vue-instantsearch components that you use including each refinement attribute
113+
h(AisHits),
114+
]);
115+
},
116+
},
98117
},
99-
},
100-
},
101-
renderToString,
102-
})
118+
renderToString,
119+
});
103120
})
104121
```

0 commit comments

Comments
 (0)