我正在使用parse-server,並且想要像下面的示例那樣使用nodejs和cloudCode。parse-server cloudCode with nodejs
這是例如: Adding nodejs to Parse
這裏是從鏈路的示例代碼
var http = require('http');
var express = require('express');
var bodyParser = require('body-parser');
var ParseCloud = require('parse-cloud-express');
var Parse = ParseCloud.Parse;
var app = express();
// Host static files from public/
app.use(express.static(__dirname + '/public'));
// Define a Cloud Code function:
Parse.Cloud.define('hello', function(req, res) {
res.success('Hello from Cloud Code on Node.');
});
// Mount the Cloud Code routes on the main Express app at /webhooks/
// The cloud function above will be available at /webhooks/function_hello
app.use('/webhooks', ParseCloud.app);
// Launch the HTTP server
var port = process.env.PORT || 80;
var server = http.createServer(app);
server.listen(port, function() {
console.log('Cloud Code on Node running on port ' + port + '.');
});
的console.log(process.env.PORT);
我已經導入了所有需要的模塊,不過,當我運行的服務器,並嘗試去鏈接「127.0.0.1/webhooks/function_hello」我回來Cannot GET /webhooks/function_hello
任何建議?
* OUTPUT當我運行該腳本*
undefined
Cloud Code on Node running on port 80.
UPDATE似乎與他們改變支持地位cloudcode解析的關閉影響使用的NodeJS它整合
您可以在執行服務器時添加控制檯的輸出嗎? – Duane
我已加入 – user3676224
嘗試發帖127.0.0.1:80/webhooks/functions/hello。 – ChunTingLin