var request = require('request')

var API_URL = 'https://api.digitalocean.com/v2/'

var api = {
  call: function (options, callback) {
    options.url = API_URL + options.action
    options.headers = {
      json: true,
      Authorization: 'Bearer ' + options.token
    }

    delete options.action
    delete options.token

    request(options, function (err, res, body) {
      if (err) return callback(err)
      if (res.statusCode >= 400) return callback(JSON.parse(body), body)

      callback(null, body)
    })
  }
}

module.exports = api

var request = require('request')

var API_URL = 'https://api.digitalocean.com/v2/'

var api = {
  call: function (options, callback) {
    options.url = API_URL + options.action
    options.headers = {
      json: true,
      Authorization: 'Bearer ' + options.token,
      "Content-Type": "application/json"
    }

    delete options.action
    delete options.token

    request(options, function (err, res, body) {
      if (err) return callback(err)
      if (res.statusCode >= 400) return callback(JSON.parse(body), body)

      callback(null, body)
    })
  }
}

module.exports = api

Add Content-Type json to headers
Add Content-Type json to headers
