capejs/capejs

View on GitHub
lib/cape/mixins/check_status.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict'

function checkStatus(response) {
  if (response.status >= 200 && response.status < 300) {
    return response
  }
  else {
    let error = new Error(response.statusText)
    error.response = response
    throw error
  }
}

module.exports = checkStatus