const request = require('request')
const fs = require('fs')

const options = {
  url: '{{{service.url}}}',{{#token}}
  headers: {
    'authorization': '{{token}}'
  },{{/token}}
  qs: {{{examplJSONBareIndented}}},
  json: true{{#hasFileOutput}},
  encoding: null{{/hasFileOutput}}
}

request(options, (error, response, body) => {
  if (error) throw new Error(error)

  {{#hasFileOutput}}fs.writeFileSync('{{output}}', body){{/hasFileOutput}}{{^hasFileOutput}}console.log(body){{/hasFileOutput}}
})
