Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Twitter(options) {
user_stream_base: 'https://userstream.twitter.com/1.1',
site_stream_base: 'https://sitestream.twitter.com/1.1',
media_base: 'https://upload.twitter.com/1.1',
post_method: null,
request_options: {
headers: {
Accept: '*/*',
Expand Down Expand Up @@ -129,14 +130,10 @@ Twitter.prototype.__request = function(method, path, params, callback) {
options.qs = params;
}

// Pass form data if post
// Pass data if post
if (method === 'post') {
var formKey = 'form';

if (typeof params.media !== 'undefined') {
formKey = 'formData';
}
options[formKey] = params;
var post_method = this.options.post_method ? this.options.post_method : (params.media ? 'formData' : 'form');
options[post_method] = params;
}

// Promisified version
Expand Down
1 change: 1 addition & 0 deletions test/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Twitter', function() {
user_stream_base: 'https://userstream.twitter.com/1.1',
site_stream_base: 'https://sitestream.twitter.com/1.1',
media_base: 'https://upload.twitter.com/1.1',
post_method: null,
request_options: {
headers: {
'Accept': '*/*',
Expand Down