简体   繁体   中英

node js busboy not emitting events with angular js $http post

Busboy seems just stuck in there.

I've tested all 3 events(file, field, finish) but nothing was emitted.

My angular code is below.

$http({
    method : 'POST',
    url : mublAConfig.server + '/api/v3/user/friend',
    headers : {
        'Content-Type' : 'application/x-www-form-urlencoded',
        'Authorization' : access_token
    },
    transformRequest : function(obj) {
        var str = [];
        for (var p in obj) {
            str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
        }
        return str.join('&');
    },
    data : {
        id : $scope.writes[0].input,
        say : $scope.writes[1].input
    }
}).success(function(data) {
    console.log('Received data : ', data);
}).error(function(data) {
    console.log('Error! ', data);
});

all i did with busboy was below

req.busboy = new busboy({headers:req.headers});
req.pipe(req.busboy);
req.busboy.on('file', function(field, file, name) {
    console.log('file event');
});
req.busboy.on('field', function(name, value) {
    console.log('field event');
});
req.busboy.on('finish', function() {
    console.log('busboy finished');
});

How can i solve it?

I have completely no idea, but suddenly this problem is solved.
I did just added some test codes. And removed them. Then it works.
Oh god..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM