I am trying to the replicate an example, just change ng-model
name, and the url
to communicate the client with the server, but that error show up.
POST https://nuevohorario.herokuapp.com/enviarAsignatura 404 (Not Found)
Possibly unhandled rejection: {"data":"<h1>Not Found</h1>\n<h2></h2>\n<pre></pre>\n","status":404,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/enviarAsignatura","data":{"data":"calculo"},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"}},"statusText":"Not Found"}
.controller('ctrl-asignatura',function($scope,sk,$http){
$scope.date= new Date();
$scope.data=[];
var vector = [];
$scope.m=function(){
$http.post('/enviar', {data : $scope.asignatura}).then(function(response){
console.log(response);
})
}
sk.on('registrar',function(s){
alert(s);
});
var express = require('express');
var router = express.Router();
var misocket = require('../routes/misocket');
/* GET users listing. */
router.post('/enviar', function(req, res, next) {
console.log(misocket);
misocket.emit("registrar",req.body);
console.log(req.body);
res.status(200).json({
message : "send message"
});
});
module.exports = router;
var i =0;
var ioapp;
exports.connection= function(io){
ioapp=io;
io.on('connect',function(s){
console.log("conetado");
})
}
exports.io=ioapp;
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
It seems you are useing Router-level middleware
var router = express.Router()
Try to load router-level middleware by using the router.use() functions.
router.use('/enviarAsignatura', function(req, res, next) {
//your code here
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.