Hi team.
i need to get response from elastic that data is written and then return success, but now endpoint returns success when data is sent for recording. how to do that?
server.route({
method: 'POST',
path: '/api/newinv',
async handler(req, h) {
const payload = req.payload;
await callWithRequest(req, 'bulk', {
index: 'myindex',
body: [
{ "index" : { "_index" : "myindex", "_type" : "doc" }},
payload,
]
})
.then(response => {
console.log("WRITTEN");
console.log({ error: null, id: response._id, result: response.result });
})
.catch(error => {
console.log({ error: error });
});
return "SUCCESS";
},
});