Webhook data handling after request

Hi all,

Can we somehow handle response data after the webhooking? Example from here could return a response of the API directly to the page.

  webhook: { // This is the object that will be used to fire http calls.
    url: 'http://my-company-name', // The url of the company providing the service.
    method: 'POST', // The method you would like to use (typically a POST).
    headers: { }, // You can add some headers if needed (you can remove it).
    body: { // A body to send to the url (only JSON supported).
      adminToken: 'your-admin-token',

But could we fetch the response data to do something with it and then send that data to the page?


Hi @Bojan_Antonijevic,

I’m not sure to understand your need here. What response data would you like to fetch exactly?

Hi @lamatt_v,

Any data which we receive from API, no related much to example from the original comment. But for example, if have API endpoint: domain.com/users/cities and we know the response is:

     ['id' =>0, 'city'=>'Berlin']
     ['id' =>1, 'city'=>'Washington DC']
     ['id' =>2, 'city'=>'Uzice']

Webhook will look like this:

webhook: {
    url: 'domain.com/users/cities',
    method: 'GET',

We want to implement it in the routes:

router.get('/users', permissionMiddlewareCreator.list(), (request, response, next) => {

Route retrieve default information about users, for example:

     ['id' =>0, 'name'=>'John', 'country'=>'Germany']
     ['id' =>1, 'name'=>'Valentin', 'country'=>'USA']
     ['id' =>2, 'name'=>'Doe', 'country'=>'Serbia']

But we want to join cities in country field for the final result:

     ['id' =>0, 'name'=>'John', 'country'=>'Germany - Berlin']
     ['id' =>1, 'name'=>'Valentin', 'country'=>'USA - Washington DC']
     ['id' =>2, 'name'=>'Doe', 'country'=>'Serbia - Uzice']

And for that, we need to:

  1. Get default info:
  const recordsGetter = new RecordsGetter(tsheet_users);
  const params = request.query;
  params.searchExtended = true;
    .then((records) => {
  1. Get a response from the webhook:
webhook: {
    url: 'domain.com/users/cities',
    method: 'GET',
  1. Handle data to join cities to country field.
    4.Return response:
.then(recordsSerialized => response.send(recordsSerialized))

From all of this we just wandering how to get data from the webhook? :slight_smile:

I’m not quite sure that webhooks are what you need here.

Webhooks are intended to perform a post request after an action (when received by the UI). If I’m not mistaking what you’re looking for is to make an http call during the action process to merge the results to the one you want to send back right?

1 Like

Yea, that’s correct. So if we could not work with webhooks I guess we could use superagent, axios, got or similar?

Exactly you should just simply do the request on your side :wink:

1 Like