Guest User

Untitled

a guest
May 22nd, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. //Insert user
  2. router.post('/', async function(request, response) {
  3. let object = {
  4. name: request.body.userName,
  5. password: request.body.userPassword
  6. }
  7.  
  8. let insert = await serviceUser.insert(object);
  9. console.log(insert); //Aqui mostra todos os dados (id inserido, número de inserts, etc)
  10. response.send(insert);
  11. });
  12.  
  13. $http({
  14. method: method,
  15. url: 'http://localhost:3000/user',
  16. data: {userName: 'teste', userPassword: '123abc'},
  17. mode: 'no-cors'
  18. })
  19. .then(function(response) {
  20. $scope.dataResponse = response;
  21. 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 }
  22. })
  23. .catch(error => console.log(error));
Add Comment
Please, Sign In to add comment