Skip to content

Commit

Permalink
Merge pull request #381 from Rowadz/fix/remove-reserved-word-usage
Browse files Browse the repository at this point in the history
fix: using await in the html file for the hapi middleware
  • Loading branch information
LunaticMuch committed Feb 9, 2024
2 parents 55575b2 + c01ae3e commit ae28413
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/middleware/render-voyager-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,29 @@ export default function renderVoyagerPage(options: MiddlewareOptions) {
<h1 style="text-align: center; color: #5d7e86;"> Loading... </h1>
</main>
<script type="module">
window.addEventListener('load', async function(event) {
const response = await fetch('${endpointUrl}', {
window.addEventListener('load', function (event) {
fetch('${endpointUrl}', {
method: 'post',
headers: Object.assign({}, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, ${headersJS}),
headers: Object.assign(
{},
{
Accept: 'application/json',
'Content-Type': 'application/json',
},
${headersJS}
),
body: JSON.stringify({
query: GraphQLVoyager.voyagerIntrospectionQuery,
}),
credentials: 'include',
});
const introspection = await response.json();
GraphQLVoyager.renderVoyager(document.getElementById('voyager'), {
introspection,
displayOptions: ${JSON.stringify(displayOptions)},
});
})
.then((response) => response.json())
.then((introspection) => {
GraphQLVoyager.renderVoyager(document.getElementById('voyager'), {
introspection,
displayOptions: ${JSON.stringify(displayOptions)},
})
})
})
</script>
</body>
Expand Down

0 comments on commit ae28413

Please sign in to comment.