diff --git a/x-pack/plugins/searchprofiler/public/templates/index.html b/x-pack/plugins/searchprofiler/public/templates/index.html
index 3b9346a00829..0530413b42b0 100644
--- a/x-pack/plugins/searchprofiler/public/templates/index.html
+++ b/x-pack/plugins/searchprofiler/public/templates/index.html
@@ -18,7 +18,7 @@
-
+
{
+ handler: async (request) => {
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
let parsed = request.payload.query;
@@ -33,18 +33,18 @@ export function profileRoute(server, commonRouteConfig) {
type: request.payload.type,
body: parsed
};
-
- callWithRequest(request, 'search', body).then((resp) => {
+ try {
+ const resp = await callWithRequest(request, 'search', body);
return {
ok: true,
resp: resp
};
- }).catch((err) => {
+ } catch (err) {
return {
ok: false,
err: err
};
- });
+ }
}
});