Created
November 2, 2022 23:09
-
-
Save talcual/ffa2f94652faa3bb274745f0f2db84e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
var Notas = require('../models/Notas'); | |
/* Creating Device */ | |
router.post('/create', async function(req, res, next) { | |
try { | |
const response = await Notas.create({ | |
titulo : req.body.title, | |
contenido : req.body.content, | |
create_at : req.body.create_at, | |
owner : req.body.owner | |
}).then(function(data){ | |
const res = { success: true, data: data, message:"created successful" } | |
return res; | |
}).catch(error=>{ | |
const res = { success: false, error: error } | |
return res; | |
}) | |
res.json(response); | |
} catch (e) { | |
console.log(e); | |
} | |
}); | |
/* Update device data */ | |
router.post('/update_nota', async function(req, res, next) { | |
try { | |
const response = await Notas.findByPk(req.body.serial) | |
.then(function(nota){ | |
if (nota) { | |
device.update(req.body).success(function () { | |
const res = { success: true, data: data } | |
}) | |
} | |
return res; | |
}).catch(error =>{ | |
const res = { success: false, error: error } | |
return res; | |
}) | |
res.json(response); | |
} catch (e) { | |
console.log(e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment