无法加载资源:404(未找到) - 数据未传递到后端

时间:2017-05-29 20:27:54

标签: javascript angularjs node.js

当我读取并将这些数据发送到后端时,我收到404错误。

enter image description here

我有一个MEAN网络应用程序..我已经添加了wriiten代码

控制器

$scope.addFileContents= function(readDetails)
{
var lines = readDetails.split('\n');
for(var line = 0; line < lines.length-1; line++){
var logFileContent = ""; 
var linesSpace = lines[line].split(' ');
for(var y=3;y <= linesSpace.length-1;y++){
logFileContent +=linesSpace[y];
logFileContent += " ";
  }   
var event = {
dat: linesSpace[0],
tim: linesSpace[1],
details: logFileContent,  
 };
 Event.ReadUploadFile(event)
  .success(function () {
      $scope.status = 'Reading the selected file';          
  })
  .error(function (error) {
      $scope.status = 'Unable to insert data: ' ;
  });

} }

服务

  ReadUploadFile : function(event) {
        return $http.post('/api/filesReadUpload', event);
        $window.location.reload();
    },

路线

app.post('/api/filesReadUpload', function(req, res) {

    var events=new filesReadUpload({

        dat:req.body.dat,
        details:req.body.details,
        tim:req.body.tim,
             });

    events.save(function(err) {
        if (err)
        return res.send(err);

        res.json({    message: 'Read file!'  });
              });
        });

模型

var mongoose = require('mongoose');
var Schema  = mongoose.Schema;
var filesUpload= new Schema({

_id:String,
dat:String,
details:String,
tim:String,

},
{
versionKey: false
});
module.exports = mongoose.model('filesReadUpload',filesUpload);

任何人都可以提出解决此问题的方法吗? 感谢

0 个答案:

没有答案