Moonrise
Moonrise

Reputation: 113

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?

Upvotes: 1

Views: 452

Answers (1)

Moonrise
Moonrise

Reputation: 113

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..

Upvotes: 1

Related Questions