1

When I'm performing a put request and console.log(response) of the request I only get a JSON Object like {"res":1} instead of getting the whole json object with its changes in order to update him in a database.

Controller :

$scope.doneEdit = function (components) {
        console.log(components);
        components.editing = false;
        if (components.editing === false) {
            $http.put('/propt/' + components._id).then(function (response) {
                console.log(response.data);
            });
        }
    }

Express

app.put('/propt/:id', function(req,res) {
    console.log(req.body);
    testDb.update({_id:req.params.id}, req.body, {}, function(err, numReplaced){
        res.statusCode = 200;
        res.send(req.body);
    })
})
1
  • add some code, the code in your controller and the code in your express route Commented Apr 27, 2017 at 14:50

1 Answer 1

1

You should pass the data you want to send as a second parameter to put method:

$http.put('/propt/' + components._id, {someValue:components.someValue})

You can find the documentation here: https://docs.angularjs.org/api/ng/service/$http#put

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.