How to run an Angular application with Node.JS and Express

Asked

Viewed 520 times

1

How do I link an angled login application with the Node.JS and Express server. How do I test (pull) the application to the server.

The server is running normally on port 3000:

var express = require('express');
var bodyParser = require('body-parser');
var port = '3000';

var app = express();

app.listen(port);

app.get('/login.html', function(req, res){
    var pessoa = {
        nome:'Leandro', 
        país:'Brasil',
        cpf:'457898'
    };
    res.json(pessoa);
});

1 answer

0


I usually pull like this

server.js

pastureDoProjeto

index.html

var express = require('express');
var bodyParser = require('body-parser');
var app = express();

app.use(express.static(__dirname + '/pastaDoProjeto'));
app.use(bodyParser());

var porta = 3412;

app.listen(process.env.PORT || porta, function(){
    console.log('Servidor online porta ' + porta);
});
  • Then @Felipe Duarte on Node appeared here that Bodyparser is deprecated and does not work.

  • I haven’t touched Ode in a while, but if I’m not mistaken it’s a Warning that doesn’t interrupt your code, I edited the answer to be clearer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.