Last active
November 2, 2022 23:09
-
-
Save talcual/6fb56b8f20cb38ff629be1427a00f4fa 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 Publicaciones = require('../models/Publicaciones'); | |
/* Creating Device */ | |
router.post('/create', async function(req, res, next) { | |
try { | |
const response = await Publicaciones.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_publicacion', async function(req, res, next) { | |
try { | |
const response = await Publicaciones.findByPk(req.body.serial) | |
.then(function(publicacion){ | |
if (publicacion) { | |
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