const request = require('./request')

module.exports = requestPromise

function requestPromise(opts) {
  return new Promise(function(resolve, reject) {
    request(opts, function(err, response, body) {
      if (err) {
        reject(err)
      } else if (response.statusCode !== 200) {
        const err = new Error('Status code ' + response.statusCode)
        err.response = response
        err.body = body
        reject(err)
      } else {
        resolve(body)
      }
    })
  })
}

const request = require('./request')

module.exports = requestPromise

function requestPromise(opts) {
  return new Promise(function(resolve, reject) {
    request(opts, function(err, response, body) {
      if (err) {
        reject(err)
      } else if (response.statusCode !== 200) {
        err = new Error('Status code ' + response.statusCode)
        err.response = response
        err.body = body
        reject(err)
      } else {
        resolve(body)
      }
    })
  })
}

Fix use of 'const' to redefine existing variable in tests.
Fix use of 'const' to redefine existing variable in tests.
