daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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: 'POST',
  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));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top