<commit_before>var jsend = require('jsend')
var httpify = require('httpify')

function jsendBatchedRequest(url, postParams, plural, callback) {
  httpify({
    url: url,
    method: 'POST',
    json: true,
    body: postParams
  }, function (err, res) {
    if (err) return callback(err)

    var body = res.body
    if (!jsend.isValid(body)) return callback(new Error('Invalid JSend response'))
    if (body.fail) return callback(new Error(JSON.stringify(body.data)))

    return callback(undefined, plural ? body.data : body.data[0])
  })
}

module.exports = {
  jsendBatchedRequest: jsendBatchedRequest
}
<commit_msg>utils: check body.status not body.fail<commit_after>var jsend = require('jsend')
var httpify = require('httpify')

function jsendBatchedRequest(url, postParams, plural, callback) {
  httpify({
    url: url,
    method: 'POST',
    json: true,
    body: postParams
  }, function (err, res) {
    if (err) return callback(err)

    var body = res.body
    if (!jsend.isValid(body)) return callback(new Error('Invalid JSend response'))
    if (body.status === 'fail') return callback(new Error(JSON.stringify(body.data)))

    return callback(undefined, plural ? body.data : body.data[0])
  })
}

module.exports = {
  jsendBatchedRequest: jsendBatchedRequest
}

{'fraction_non_alphanumeric': 0.13458528951486698, 'fraction_numerical': 0.001564945226917058, 'mean_word_length': 4.178137651821863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2584855', 'n_tokens_mistral': 409, 'n_tokens_neox': 406, 'n_words': 105}