我试图通过POST方法将数据传递给节点js http请求(firebase云功能)。
angular.module('app', ['ionic'])
.controller("HttpGetController", function ($scope, $http) {
var ph_array = [];
ph_array.push('a');
ph_array.push('b');
ph_array.push('c');
var data = {
ph_id : ph_array
};
$scope.GetAllData = function(){
$http.post('http://localhost:5002/xxxxx-f4286/us-central1/xxxxxxxxxxxxxxxxxxx', data).then(function successCallback(response) {
alert('success');
alert('response '+JSON.stringify(response));
alert('status '+response.status);
console.log('response '+JSON.stringify(response))
}, function errorCallback(response) {
alert('failure '+response.status+' msg '+response.data);
});
}
});
firebase云功能中的节点js
exports.xxxxxxxxxxxxxxxxxxx = functions.https.onRequest((request, response) => {
console.log('request.method '+request.method);
const ph_ids = request.body.ph_id;
console.log('ph_ids '+ph_ids);
response.send('I am done');
});
日志即将开始
info: User function triggered, starting execution
info: request.method OPTIONS
ph_ids undefined
info: Execution took 0 ms, user function completed successfully
有人可以帮我解决我在这里做错的事。