return object returned from the database to the front end

0

I'm not understanding why these returns

On server node.js:

//Insert user
router.post('/', async function(request, response) {
    let object = {
        name: request.body.userName, 
        password: request.body.userPassword
    }

    let insert = await serviceUser.insert(object);
    console.log(insert); //Aqui mostra todos os dados (id inserido, número de inserts, etc)
    response.send(insert);
});

In the angular.js client:

$http({
    method: 'POST',
    url: 'http://localhost:3000/user',
    data: {userName: 'teste', userPassword: '123abc'},
    mode: 'no-cors'
})
.then(function(response) {
    $scope.dataResponse = response;
    console.log(response); //Aqui aparece o header, status, ... e o atributo data (que contém o retorno do servivor) apenas com: { n: 1, ok: 1 }
})
.catch(error => console.log(error));

Why this? I would like the server back to have other data, how do I do this?

Note: data: { n: 1, ok: 1 } , on the front end, is equivalent to result: { n: 1, ok: 1 } , in the backend, that is, this attribute is in the back but only it is returned and not the entire parent object. I'm not making any filters to return only result

    
asked by anonymous 23.05.2018 / 03:10

0 answers