Saturday, 10 June 2017

Error 404 Node Js heroku app

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.

Error

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"}

Client -> Front - End

.controller('ctrl-asignatura',function($scope,sk,$http){

                        $scope.date= new Date();
                        $scope.data=[];
                        var vector = [];
                        $scope.m=function(){

                            //$scope.data.push($scope.informacion);
                            //console.log(vector)

                            $http.post('/enviarAsignatura', {data : $scope.asignatura}).then(function(response){
                                console.log(response);
                            })

                        }

                       sk.on('registrar',function(s){
                            alert(s);
                        });

Back End -> Node Js - Socket.IO

var express = require('express');
var router = express.Router();
var misocket = require('../routes/misocket');

/* GET users listing. */
router.post('/enviarAsignatura', 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;



via Pedro Miguel Pimienta Morales

No comments:

Post a Comment