utils/find-status/index.js

  1. import HTTP_STATUSES from '../../constants/http-statuses';
  2. /**
  3. * @description
  4. * This method finds HTTP status by specified field
  5. *
  6. * @param {String/Integer} value - The HTTP Status value to filter
  7. * @param {String} field - Find by "code" or "key"
  8. * @return {Object}
  9. */
  10. function findHttpStatus(value, field = 'code') {
  11. return HTTP_STATUSES.find(httpStatus => httpStatus[field] === value);
  12. }
  13. export default findHttpStatus;