bench-rest icon indicating copy to clipboard operation
bench-rest copied to clipboard

Get with headers

Open salasia opened this issue 8 years ago • 1 comments

how to api call with headers ? Type erros:

Object.keys(obj).forEach(function (i) {
         ^
TypeError: Object.keys called on non-object

salasia avatar Apr 26 '17 14:04 salasia

Just add the headers to any of the flow request objects.

var flow = {
    main: [
      { put: 'http://localhost:8000/foo_#{INDEX}', json: 'mydata_#{INDEX}' },
      { 
        get: 'http://localhost:8000/foo_#{INDEX}',
        headers: {
          'User-Agent': 'request'
        }
      }
    ]
  };

Since it uses request as the http client, it supports any of the options request supports.

https://github.com/request/request#custom-http-headers

jeffbski avatar Apr 26 '17 19:04 jeffbski