Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 02 2020 06:16
    @ljharb banned @frank-dspeed
  • Apr 27 2018 01:23
    @MylesBorins banned @fjeddy
  • Feb 24 2016 08:26
    @rvagg banned @jonathanenbe
Jarreddebeer
@Jarreddebeer
@ljharb Thanks
Krrunal
@Krrunal

Hi, I'm having trouble with when I store data to MySQL database I get a return in console blank.

here's route code
app.post('/create', function (req, res, next) {
var notification = req.body.notification;
console.log(req.body.notification);
var sql = INSERT INTO employee (notification_type) VALUES ('${notification}', );
db.query(sql, function (err, data) {
if (err) throw err;
console.log("record inserted");
});
res.redirect('employee');
});

here's form code

<form action="/routes/create" method="POST">
<select class="notification" id="select1" name="notification" onchange="getSelectValue();">
<!-- <option value="<%=data.notification %>"><%=data.notification %></option> -
<option value="Warning">Warning </option>
<option value="Absence">Absence</option>
<option value="Lateness">Lateness</option>
<option value="Early-leave">Early Leave</option>
<option value="leave-without-notice">Leave Without
Notice
</option>
<option value="questioning">Questioning</option>

</select>


</td>

<td><a class="btn btn-warning" type="submit">Submit</a>

</td>
</form>

mohit-techdoodles
@mohit-techdoodles

Hi, I'm having trouble with when I store data to MySQL database I get a return in console blank.like this {}

here's route code :::app.post('/create', employeeController.create);

this is my controller code
const Employee = require('../models/employee.model');

exports.create = function(req, res) {

console.log((req.body));
const new_employee = new Employee(req.body);
//handles null error
if(req.body.constructor === Object && Object.keys(req.body).length === 0){
  res.status(400).send({ error:true, message: 'Please provide all required field' });
}else{
    Employee.create(new_employee, function(err, employee) {
      if (err)
      res.send(err);
      res.json({error:false,message:"Employee added successfully!",data:employee});
    });
}

};

this is my model code:

var db = require('../database');
//Employee object create
var Employee = function(employee){
this.name = employee.name;
this.email = employee.email;
this.position = employee.position;
};

Employee.create = function (newEmp, result) {
db.query("INSERT INTO employee set ?", newEmp, function (err, res) {
if(err) {
console.log("error: ", err);
result(err, null);
}
else{
console.log(res.insertId);
result(null, res.insertId);
}
});
};

module.exports= Employee;

my view code:

<form action="/create" enctype="multipart/form-data" method="POST">
<div class="row">
<div class="col-md-6">
<label>Name</label>
<input name="name" type="text" class="form-control" required>
</div>
<div class="col-md-6">
<label>Email</label>
<input name="email" type="email" class="form-control" required>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label for="exampleFormControlTextarea1" class="form-label">Position</label>
<input name="position" type="text" class="form-control" required>
</div>

</div>

<button type="submit" class="btn btn-primary">Save</button>
<button type="submit" class="btn btn-primary">Cancel</button>
<br><br>

</form>

Im getting {} in log it means req.body is getting blank.

i have tried in app.js

app.use(bodyParser.json());
app.use(express.urlencoded({limit: '100mb',extended: false }));
but its not working

Jakub Z
@jakubiszon
@Krrunal @mohit-techdoodles what does it even mean to get a return in console blank? What is a console blank?
Also - please try narrowing your problems down a bit - e.g. check if this is a problem in your interaction between the server and the DB or between the serer and the client
mohit-techdoodles
@mohit-techdoodles
@jakubiszon Im getting {} in log it means req.body is getting blank.(it means i am not getting any value from my form or html.)i need to insert the values in db
Jakub Z
@jakubiszon
@mohit-techdoodles You have used body parser in your app ( also make sure it is added to app before the post handler ) but I think it does not support multipart/form-data by default. You only need to use that enctype when posting files. Just remove the whole enctype parameter from the <form> tag and try again.
And btw. did you check if the right payload is sent from the browser? You can use your browser dev tools network tab / feature to check that.
Isheke Peter
@peterishek
Hey guys! I'm looking to hire blockchain developers and a software programmer anyone interested can hit me up. I'm creating a crypto utility marketplace and smart tokens for operation. A market for the stock and cryptocurrency or project development
available12
@available12
hello guys i need help..I have a bot Mod for my stream..he is always on in the vps ...there is any way to make the bot join only if steam on..and leave automaticly if it off...is that possible, please help
JomoPipi
@JomoPipi
Hi everyone
I have a Node.js question:
const readStream = fs.createReadStream(fromPath)
        const writeStream = fs.createWriteStream(toPath)
        const err = (e : Error) => console.warn('Got an error here:',e)
        readStream.on('error', err)
        writeStream.on('error', err)
        readStream.pipe(writeStream)
        log('did I make it here??')
        writeStream.on('close', () => {
            log('How about here ?')
            writeStream.end()
            callback() 
        })
The first time, it always works
Every time after that, I never get to 'How about here ?'.
for some reason I can't do this operation twice
the close event only happens the first time
thanks in advance
JomoPipi
@JomoPipi
had to do with file permissions, dont worry
Seif Eddine Slimene
@SeifESlimene
app.set("strict routing", true);
app.enable('strict routing')
Doesn't work
Navid
@Navid61
Hi, everyone I'm using formidable for upload file to server but I don't know why size of uploaded files on server is fewer than before upload process approximately 0.2kb, do you know how I can be sure file did upload completely Or any solution can give me exact file size after they did upload
Tabzlock
@t4bzl0ck:matrix.org
[m]
I would just use bash I am not sure what your purpose is but it seems like your overcomplicating it and im not sure if java is the best route for a gui application.
robinlovelace
@robinlovelace:matrix.org
[m]
Hi all, just to say I've joined this as a test: it works from element.io: https://matrix.org/blog/2020/12/07/gitter-now-speaks-matrix 🎉
1 reply
Alestor Aldous
@alestor123
`hey
new Date('Dec 31').toJSON().slice(5,10) getting "12-30"
Krrunal
@Krrunal
Here's my code for variable value store when I run the code get the error in render variable in undefined I want to use var outside method : function processMessage(msg, seqno, headers) {
console.log("Processing msg #" + seqno);
        var parser = new MailParser();
        parser.on('headers', headers => {
            console.log('to2----', headers.get('to').text);
            console.log('from2----', headers.get('from').text);
            console.log('subject---', headers.get('subject'));
            console.log('date---', headers.get('date'));

            var sender = headers.get('to').text;
            var reciver = headers.get('from').text;   });

        parser.on('data', data => {
            if (data.type === 'text') {
                console.log(seqno);
                console.log('msg---', data.text);  /* data.html*/
            }
        });

        msg.on('body', function (stream) {
            stream.on('data', function (chunk) {
                parser.write(chunk.toString("utf8"));
            });
        });

        msg.once('end', function () {
            parser.end();
        });


     res.render('email-reply', { title: 'Email Reply', to: sender, from: reciver });


    }
david-zed
@david-zed
Hi, I am new to Node , I have created a node server which prints to a Star receipt printer fine for both USB and WIFI when run on Windows however, when I run it on a Mac version 10.13.3 the WIFI works fine but USB does nothing, the data gets to the printer queue ok but then just dissappears into the ether. On windows I use the thermal-printer module ( built from source ) which works great, but on MAC ( again built from source ) the USB does nothing so I tried the node printer module ( also built from source ) and still nothing.
david-zed
@david-zed
var CD_INITIALIZE = Buffer.from([ 0x1b, '@']);
var CD_KICK       = Buffer.from([0x1b, 0x07, 0x0b, 0x37, 0x07]);
var CD_FONT       = Buffer.from([0x1b, 0x1e, 0x46, 0x00]);
var CD_BOLD       = Buffer.from([0x1b, 0x45 ]);
var CD_NORMAL     = Buffer.from([0x1b, 0x46 ]);
var CD_CUT        = Buffer.from([0x1b, 0x64, 0x30]);

//var deviceName = '_192_168_1_106';
var deviceName = 'Star_TSP143__STR_T_001_';

var message    = "\nDaffodil              10.00\nTulips                23.00\n"
var shopHeader = "Flowers\nBy\nDavid";

const printer = require('printer');

printRaw( CD_INITIALIZE, deviceName );
printRaw( CD_FONT, deviceName );
printRaw( CD_BOLD, deviceName );
printText( shopHeader , deviceName );
printRaw( CD_NORMAL, deviceName );
printText( message , deviceName );
printRaw( CD_CUT, deviceName );


function printRaw( data, printerName ) {
    printer.printDirect({
        data:    data,
        printer: printerName,
        type:    'RAW',
        success: function( jobId ) {
            console.log("Print RAW completed OK");
        },
        error: function( err ) {
            console.log("Print RAW error [" + err + "]");

        }
    });
};
function printText( data, printerName ) {
    printer.printDirect({
        data:    data,
        printer: printerName,
        type:    'TEXT',
        success: function( jobId ) {
            console.log("Print TEXT completed OK");
        },
        error: function( err ) {
            console.log("Print TEXT error [" + err + "]");

        }
    });
};
Siemienik Pawel
@Siemienik

I've released the alpha version of spreadsheet files importer cli: sxi. More details may be found on the package readme:
https://github.com/Siemienik/XToolset/blob/master/packages/xlsx-import-cli/README.md

(xlsx-import-cli is part of XToolset - set of high level api tools for XLSX files).

Any feedback welcomed, any stars loved :heart: .

1 reply
Jordan Harband
@ljharb
how does xtoolset differ from sheetjs
david-zed
@david-zed
Hi, I am trying to run a NODE server as a windows service but when I try to start it I get error 1053, it does not respond in a timely manner. I have checked all the suggestions provided by MS including setting ServicesPipeTimeout value in registry but still same error, my bat script is as follows:
@echo off
set STS_HOME=d:\TerminalServer
set NODE_HOME=d:\Node
del %STS_HOME%/log/sts.log
start /b %NODE_HOME%\node "%STS_HOME%\terminalServer.js" > %STS_HOME%/log/sts.log
david-zed
@david-zed
Found this which worked really well npm install -g qckwinsvc,
Michael Carleton
@micycle1

I'm trying to port this js to java

if (cells[i0] & W && distance[i1 = i0 - 1] === undefined) distance[i1] = d, frontier1.push(i1);

i1 is reassigned during the array reference -- what does the value of i1 in distance[i1] take?
the new val or old val?
Also,
Cells[i0] and W are both numbers, so "cells[i0] & W" performs a bitwise AND, then the "&&" evaluates the truthy of this, where only the number 1 is true -- is this correct?

Covenant Simon
@ccurves
Hi am fairly new to nodejs and am currently working on a project
Shekhar Ramola
@shekharramola
image.png
how do I fix this error?
I kept getting this when running a function
it is a huge operation I am doing
there are a lot of records which i am saving in the data base
Rob Simpson
@pertrai1
Hello everyone. This is my first time in here. Wanted to say hi
Erik Kralj
@erikvimz
o/
Sahil
@Jsthil99_twitter
Hello everyone
G. Szabi
@haaami01
greetings
Yousef Amar
@amar:amar.io
[m]
Hi all from Matrix!
Githubber2021
@Githubber2021
Hi everyone!
Can anyone help me? Does anyone know how to set the hash of a crypto.Hash object?
I have a sha256 hex string as input and need to convert it into such object
Tim
@tim:schumacher.im
[m]
Greetings from the Matrix 😀
codesleuth
@codesleuth:matrix.org
[m]
Yes hello! Tank cut the hard line and here we all are
Jakub Barczyk
@jakubbarczyk
I've written a short poem for all the Node people out there... ehm!
Matrix is green and so is Node
I can't express how I love to code!

:-)