0

I'm using nodejs, mongodb, angular and html to make a RESTful service. I'm new at this and I have some problems!

With the next code of the controller, I'm sending the variable "fp" to my database:

$http.post('/fplist', $scope.fp);

It works pretty well but "fp" value is:

fpdia: Wed Nov 01 2017
fphora: 00:00:00
fppilot:{_id: "59f06a0f907c783d6ccb8901", nombre: "Mike Ross", iden: "111222333A", rpasenable: "Phantom1", $$hashKey: "object:10"}
fprpas:{_id: "59f1b8bbdbae0a23208d0ad8", model: "Phantom1", serial: "4444-444-4444", plate: "123 TT", $$hashKey: "object:14"}
fptitulo:"Test"

And I just want to save "fp" like:

fpdia: Wed Nov 01 2017
fphora: 00:00:00
fppilot: Mike Ross
fprpas: 123 TT
fptitulo:"Test"

1 Answer 1

2

You have to create another json object:

So, before you do your http request you just have to do this:

var obj = {
    fpdia: $scope.fp.fpdia,
    fphora: $scope.fp.fphora,
    fppilot: $scope.fp.fppilot.nombre,
    fprpas: $scope.fp.fprpas.plate,
    fptitulo: $scope.fp.fptitulo
}

$http.post('/fplist', obj);
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.