简体   繁体   中英

Error "Provisional headers are shown" on chrome

I created an api, when I call it have to remove an image from database. As database I used mongodb, and to manage images I use gridfs.

This is the code that calls api that remove an image from database.

vm.delete = function(img){        
    $http.delete(baseImage + img)
    .success(function(data){
        console.log(data);
    }).error(function(error){
        console.log(error);
    });
};

And this is the code of API

gfs.exist({_id: req.params._idImg}, function (err, found) {
    if(found){
        gfs.remove({ _id: req.params._idImg }, function (err) {
            if(err){
                throw err;
            }
            repliesManager(res, 200, {"message":"OK"}, "OK");
        });
    }
});

But when I call this API, the image is cleared, but the server stops, and the result is an error. It gives me this error only if you use Chrome, and the error is "Provisional headers are shown".

This is the code of repliesManager

module.exports = function(res, status, data, message, err) {
    var respObj = {
        error: err,
        data: data,
        message: message
    };

    res.status(status);
    return res.json(respObj);
};

The response isn't being processed by the browser, most likely because it hasn't been received, most likely because it hasn't been sent. Since the remove operation apparently succeeds, the problem may be in your repliesManager component or in the way you're calling it. Posting that code here would allow further analysis, as would the error output of your server.

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