diff --git a/lib/mastodon.js b/lib/mastodon.js index 67a23556..edc86001 100644 --- a/lib/mastodon.js +++ b/lib/mastodon.js @@ -182,7 +182,10 @@ Mastodon.prototype._buildReqOpts = function (method, path, params, callback) { } else { // Non-file-upload params should be url-encoded if (Object.keys(finalParams).length > 0) { - reqOpts.url += this.formEncodeParams(finalParams); + if (request === 'GET') + reqOpts.url += this.formEncodeParams(finalParams); + else + reqOpts.body = this.formEncodeParams(finalParams).replace(/^\?/, ''); } } @@ -214,7 +217,8 @@ Mastodon.prototype._doRestApiRequest = function (reqOpts, mastoOptions, method, // surface this to the caller var err = helpers.makeMastodonError('JSON decode error: Mastodon HTTP response body was not valid JSON') err.statusCode = response ? response.statusCode: null; - err.allErrors.concat({error: jsonDecodeError.toString()}) + err.allErrors.push({error: jsonDecodeError.toString()}); + err.mastodonReply = body; callback(err, body, response); return }