source.on is not a function
See original GitHub issueconst request = require('request-promise');
const req = require('request')
const fs = require('fs');
const FormData = require('form-data')
function readImage(){
return new Promise(function(resolve, reject) {
fs.readFile('./img/150150.gif', (err, data) => {
if(err) reject(err);
resolve(data);
});
});
}
readImage().then(data => {
let dat = toArrayBuffer(data);
let filename = new Date().getTime();
let formData = new FormData();
formData.append('imageClass', 'twitterApp');
formData.append('X-Requested-With', 'Iframe')
formData.append('X-HTTP-Accept', 'application/json, text/javascript, */*; q=0.01')
formData.append('file', dat, "twitterLogo");
request.post({url: 'example.com/api/images/', data: dat, processData: false, contentType: false, type: 'POST'}).then(data => {
console.log(data)
}).catch(err =>{
console.log(err);
})
}).catch(error => {
console.log(error);
})
function toArrayBuffer(buf) {
var ab = new ArrayBuffer(buf.length);
var view = new Uint8Array(ab);
for (var i = 0; i < buf.length; ++i) {
view[i] = buf[i];
}
return ab;
}
request.post says that source.on is not a function, though, I have no idea why that’d be. This is attempting to send an image file.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
TypeError: source.on is not a function · Issue #2366 - GitHub
I'm trying to POST an array of values to a HTTP endpoint, and this is the error I receive: TypeError: source.on is not...
Read more >Getting ERROR: uncaughtException: source.on is not a ...
When you call createFormData with myJson as parameter, you will see exception source.on is not a function ! And we keep thinking where...
Read more >Error Received: Source.on is not a function - App Platform
Hello Team, I am trying to create a ticket in Freshdesk along with attachments, but I am getting an error. The Error is:...
Read more >"source.on is not a function" for discord.js - Questions - n8n
I figured out how to pass the parameters on to the content, but now I am having the issue of a function being...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am getting error:
TypeError: source.on is not a function at Function.DelayedStream.create (/node_modules/delayed-stream/lib/delayed_stream.js:33:10) at FormData.CombinedStream.append (/node_modules/combined-stream/lib/combined_stream.js:44:37) at FormData.append (/node_modules/form-data/lib/form_data.js:74:3) at appendFormValue (/node_modules/request/request.js:323:21) at Request.init (/node_modules/request/request.js:334:11) at new Request (/node_modules/request/request.js:128:8) at request (/node_modules/request/index.js:53:10)
My code is:Request Version: request@2.85.0
node version: node v9.8.0
https://github.com/request/request/issues/1495 related?