我的角度客户端有一个如下所示的postrequest:
$http.post("api/login/", { foo: 'bar' }).success(function(data, status) {
$scope.hello = data;
})
服务器以express:
实现var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var cors = require('cors');
var express = require('express');
var request = require('request');
app.set('port', process.env.PORT || 3000);
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/api/login', function(req, res) {
res.send({message:'hello from api/login'});
});
app.listen(app.get('port'), function() {
console.log('Express server listening on port ' + app.get('port'));
});
当我点击“登录”时出现错误:
Status Code:405 Method Not Allowed
如何解决此错误? github上:https://github.com/dimitri-a/oauth_stuff