/api --> api
This commit is contained in:
parent
1dbb310560
commit
e12bd98dbb
@ -34,7 +34,7 @@ const CreateMsgRouter = {
|
|||||||
var tag=$("#tag").val();
|
var tag=$("#tag").val();
|
||||||
var user=$("#user").val();
|
var user=$("#user").val();
|
||||||
console.log ("Message Created: "+tag+" "+message+" "+user);
|
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) {
|
function have_result (res) {
|
||||||
console.log (res);
|
console.log (res);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ const HomeRouter = {
|
|||||||
});
|
});
|
||||||
},*/
|
},*/
|
||||||
list_messages: function () {
|
list_messages: function () {
|
||||||
$.ajax({url: "/api/ids", method: "GET"})
|
$.ajax({url: "api/ids", method: "GET"})
|
||||||
.done(jd => {
|
.done(jd => {
|
||||||
// NICHT SO wg. Vue: _messagelist = jd;
|
// NICHT SO wg. Vue: _messagelist = jd;
|
||||||
_messagelist.splice(0, _messagelist.length);
|
_messagelist.splice(0, _messagelist.length);
|
||||||
@ -48,7 +48,7 @@ const HomeRouter = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function get_insert_message(id) {
|
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);
|
Vue.set(_messages, id, msg);
|
||||||
}).fail(function (e, f, g) {
|
}).fail(function (e, f, g) {
|
||||||
console.log("cannot load " + id + ".json: " + e + f + g);
|
console.log("cannot load " + id + ".json: " + e + f + g);
|
||||||
|
10
server.js
10
server.js
@ -103,7 +103,7 @@ mongoose.connect(dbConfig.url)
|
|||||||
|
|
||||||
//require('./app/routes/message.route.js')(app);
|
//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 => {
|
Message.find({},{id: true}) .exec () .then(results => {
|
||||||
//selects id from message:
|
//selects id from message:
|
||||||
var parsed = [];
|
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){
|
Message.findOne ({_id: req.params.id}) .exec (function (err, results){
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log (err);
|
console.log (err);
|
||||||
@ -131,7 +131,7 @@ app.get ("/api/msg/:id", function (req, res) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function makeid() {
|
/*function makeid() {
|
||||||
var text = "";
|
var text = "";
|
||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
@ -139,9 +139,9 @@ function makeid() {
|
|||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
app.post("/api/createMsg", function(req, res){
|
app.post("api/createMsg", function(req, res){
|
||||||
//x = mongoose.Types.ObjectId();
|
//x = mongoose.Types.ObjectId();
|
||||||
//y = x.toString();
|
//y = x.toString();
|
||||||
//var z = makeid();
|
//var z = makeid();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user