# Get response after recorded

**URL:** <https://discuss.elastic.co/t/get-response-after-recorded/193936>\
**Category:** Kibana\
**Created:** [August 6, 2019, 6:40am UTC](https://discuss.elastic.co/t/get-response-after-recorded/193936 "2019-08-06T06:40:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [August 6, 2019, 6:40am UTC](https://discuss.elastic.co/t/get-response-after-recorded/193936/1 "2019-08-06T06:40:13Z")

</div>

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";
  },
});
```

---

<div class="post-metadata">

**Author:** ![christophilus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophilus/32/42991_2.png) [@christophilus](https://discuss.elastic.co/u/christophilus)\
**Post date:** [August 6, 2019, 3:46pm UTC](https://discuss.elastic.co/t/get-response-after-recorded/193936/2 "2019-08-06T15:46:03Z")

</div>

I think you'd want to use the refresh parameter: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html#docs-refresh](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html#docs-refresh)

So, probably you want either `refresh=true` or `refresh=wait_for`. Both have their drawbacks, and I'd say it really depends on how much writing you're doing as to whether or not you want to do this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 3, 2019, 3:56pm UTC](https://discuss.elastic.co/t/get-response-after-recorded/193936/3 "2019-09-03T15:56:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
