Example of POST /query request please

Hi, didn’t find any examples in documentations but it says we can use RES API for query. Say my query is simple:

    events = query_bucket("my_bucket");
    events = merge_events_by_keys(events, "merged_key1", "merged_key2");
    RETURN = events;

How should it look in POST request with JS? Where the QUERY should actually be?
Is it something like this?

   fetch("http://localhost:5600/api/0/query" , { 
     method: 'POST',
     body: {
      events: 'query_bucket("my_bucket")',
      return: 'events'
    }
   })

Ok, I’ve found the SWAGGER http://localhost:5600/api/swagger.json and http://localhost:5600/api/
So it say:

    {
       timeperiods* [  List of periods to query  string]
       query* [ String list of query statements string]
    }

Sorry for late reply.

The query field is documented in the swagger documentation you found, string list of query statements.

So the body of the POST request would look something like this:

{
  'timeperiod': ['2021-01-01T00:00:00+00:00/2021-02-01T00:00:00+00:00'],
  'query': [
    'events = query_bucket("my_bucket");',
    'events = merge_events_by_keys(events, "merged_key1", "merged_key2");',
    'RETURN = events;'
  ]
}