Ahmad00100
1 month ago

sending data from Laravel to node js server in Laravel application

Posted 1 month ago by Ahmad00100

problem with receiving data from the application form to node js server, the data don't apperea my from. in blade.php

        var subject = $('#subject').val().trim();
        var email = $('#to-Email').val().trim();
        var body = $('#Email-body').val().trim();

        const data = {
            subject, email, body
        };

        $.post('/mail', data, () => {
            console.log('Server receive data');
        });
    });

my node js server.js

var http = require('http');
var express = require('express');
// var js = require('./send_mail');
var app = express();
var path = require('path');

app.use(express.urlencoded({
    extended: false
}));
app.use(express.json());
app.get('http://127.0.0.1:8000/en/admin/offer');

app.post('/mail', (req, res) => {

    console.log(req.body);
});

app.listen('8000');

console.log('Your node server start successfully....');

exports = module.exports = app;

Please sign in or create an account to participate in this conversation.