我在Angular和Rails中的后端应用程序中有一个前端应用程序。为了便于维护,我完全将这两个解耦。我有一个名为Document具有三个不同的参数(User_id(integer),Data(json),Title(string))的模型。在我的前端,我有一个名为formData
的变量,它是在Angular中生活在localStorage
中的json数据。我不确定我是否正确编写代码以将formData
作为参数发送到下面的HTTP请求中。使用Angular/Rails使用params发送http请求
这里是我的要求:
$http.post('http://localhost:3000/documents', { user: $scope.user, formData: $scope.formData }, function (response) {
$scope.isSaved = true;
console.log(response);
if (response.success) {
console.log("It has been successfully saved!")
}
});
我发送请求的起源是http://localhost:3001/i129
。在这个网站上,我需要提取用户所在的文档标题(这是i129)和User_ID。我怎么做?
我是否正确地发送formData
以上?比方说,