Комментарии:
Nice tuto, i wait for more.!!! XD
Ответитьinvalid input syntax for integer: "undefined"
"D:\JetBrains\WebStorm 2017.2.3\bin\runnerw.exe" D:\nodejs\node.exe D:\timesheet\app.js
Server started
{ error: invalid input syntax for integer: "undefined"
at Connection.parseE (D:\timesheet\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (D:\timesheet\node_modules\pg\lib\connection.js:371:19)
at Socket.<anonymous> (D:\timesheet\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
name: 'error',
length: 98,
severity: 'ERROR',
code: '22P02',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'numutils.c',
line: '62',
routine: 'pg_atoi' } undefined
{ error: invalid input syntax for integer: "undefined"
at Connection.parseE (D:\timesheet\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (D:\timesheet\node_modules\pg\lib\connection.js:371:19)
at Socket.<anonymous> (D:\timesheet\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
name: 'error',
length: 98,
severity: 'ERROR',
code: '22P02',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'numutils.c',
line: '62',
routine: 'pg_atoi' } undefined
Here is the code
app.delete ('/delete/:employee_id', function(req,res){
const text = "DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID=$1"
pool.query(text,[req.params.employee_id], (err, res1) => {
console.log(err, res1);
// pool.end()
});
const client = new Client({
connectionString: connectionString,
})
client.connect()
client.query(text,[req.params.employee_id], (err, res1) => {
console.log(err, res1)
client.end()
res.sendStatus(200);
});
some how values on req.params.employee_id parameter is not getting
Here is the delete.js
$(document).ready(function(){
$('.delete-salary').on('click',function(){
var employee_id = $(this).data('employee_id');
var url = '/delete/'+employee_id;
if(confirm('Delete Recipe?')){
$.ajax({
url: url,
type: 'DELETE',
success: function(result) {
console.log('Deleting Recipe...');
window.location.href = '/';
},
error:function(err){
console.log(err);
}
});
}
});
});
Here is the button
<button class="btn btn-danger delete-salary data-id="{employee_id}">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
(TRAVERYSY STUDENTS I installed nodemon to help with the things. )
ОтветитьIn the new version I have to replace the 2nd line to: $("button.btn.delete-recipe").click(function(){
ОтветитьDo you have tutorial how can I use turn ajax into fetch API with postgresql
Ответить