私には問題があり、問題はわかりません。解決策を見つけるのを手伝ってください。req.bodyは明示的に4.13.1で定義されていません
私は角ビューで:クライアント側(AngularJS)において
<form ng-submit="submit()">
<input ng-model="stickie_text" type="text" id="sticky_content" />
<button type="submit" id="add_sticky" value="add a new stickie!">new sticky</button>
私はこのコントローラを持っている:サーバ側の
dcuApp.controller('rankingController', ['$scope', '$http',function($scope, $http) {$scope.submit = function(){
// console.log("holaaaa");
console.log($scope.stickie_text);
$http.get('/api/get-ranking',{"valor":$scope.stickie_text}).then(function(response) {
$scope.data = response.data;
console.log("RANKING: "+$scope.data);
},
function(response) {
console.debug('Error:' + response);
});
};
}]);
(エクスプレス4.13.1 )私は持っている:
問題はreq.body.valorがUNDEFINEDであることです。
この問題に関連する他の投稿はありますが、それを修正することはできませんでした。
、私は未定義
おかげで異なるreq.body.valor、サーバー側で取得するには助けを必要としてください! :)
あなたはGETリクエストをしていますか? – adeneo
@adeneoが正しければ、クライアントサイドだけでなくサーバ側でもリクエストを 'post'に変換する必要があります。そうでなければ、パラメータはクエリパラメータとしてURLの中に追加されます –