@@ -34,7 +34,7 @@ const CreateMsgRouter = { | |||
var tag=$("#tag").val(); | |||
var user=$("#user").val(); | |||
console.log ("Message Created: "+tag+" "+message+" "+user); | |||
$.ajax ({ url: "/api/createMsg", data: {sub: subject, mess: message, use: user, ta: tag}, method: "POST" }) .done (have_result) .fail (have_error); | |||
$.ajax ({ url: "api/createMsg", data: {sub: subject, mess: message, use: user, ta: tag}, method: "POST" }) .done (have_result) .fail (have_error); | |||
function have_result (res) { | |||
console.log (res); | |||
} |
@@ -24,7 +24,7 @@ const HomeRouter = { | |||
}); | |||
},*/ | |||
list_messages: function () { | |||
$.ajax({url: "/api/ids", method: "GET"}) | |||
$.ajax({url: "api/ids", method: "GET"}) | |||
.done(jd => { | |||
// NICHT SO wg. Vue: _messagelist = jd; | |||
_messagelist.splice(0, _messagelist.length); | |||
@@ -48,7 +48,7 @@ const HomeRouter = { | |||
}; | |||
function get_insert_message(id) { | |||
$.ajax({ url: "/api/msg/"+id, method: "GET" }).done(function (msg) { | |||
$.ajax({ url: "api/msg/"+id, method: "GET" }).done(function (msg) { | |||
Vue.set(_messages, id, msg); | |||
}).fail(function (e, f, g) { | |||
console.log("cannot load " + id + ".json: " + e + f + g); |
@@ -103,7 +103,7 @@ mongoose.connect(dbConfig.url) | |||
//require('./app/routes/message.route.js')(app); | |||
app.get ('/api/ids', function (req, res) { | |||
app.get ('api/ids', function (req, res) { | |||
Message.find({},{id: true}) .exec () .then(results => { | |||
//selects id from message: | |||
var parsed = []; | |||
@@ -119,7 +119,7 @@ app.get ('/api/ids', function (req, res) { | |||
}); | |||
}); | |||
app.get ("/api/msg/:id", function (req, res) { | |||
app.get ("api/msg/:id", function (req, res) { | |||
Message.findOne ({_id: req.params.id}) .exec (function (err, results){ | |||
if (err) { | |||
console.log (err); | |||
@@ -131,7 +131,7 @@ app.get ("/api/msg/:id", function (req, res) { | |||
}); | |||
}); | |||
function makeid() { | |||
/*function makeid() { | |||
var text = ""; | |||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |||
@@ -139,9 +139,9 @@ function makeid() { | |||
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |||
return text; | |||
} | |||
}*/ | |||
app.post("/api/createMsg", function(req, res){ | |||
app.post("api/createMsg", function(req, res){ | |||
//x = mongoose.Types.ObjectId(); | |||
//y = x.toString(); | |||
//var z = makeid(); |