简体   繁体   English

如何将发布数据发送到服务器端node.js应用程序?

[英]How do I send post data to my server side node.js application?

I have a server side node js application which sends me all of the facebook posts from a specified page since a desired date. 我有一个服务器端节点js应用程序,自期望日期以来,该应用程序将指定页面上的所有facebook帖子发送给我。

Up until now I have been running the application on my terminal using npm start [facebook page name] [sinceDate] . 到目前为止,我一直在使用npm start [facebook page name] [sinceDate]在终端上运行该应用程序。

Now that my app is running smoothly I would like to add some front end into the mix. 现在我的应用程序运行顺利,我想添加一些前端。 On an index.html page (located at app/views/index.html ) I have created an input form which takes in the facebook page name and sincedate arguments. 在index.html页面(位于app/views/index.html )上,我创建了一个输入表单,该表单接受了facebook page namesincedate参数。

I was wondering if anyone had any advice on how to send this post data to my server side node application? 我想知道是否有人对如何将此post数据发送到服务器端节点应用程序有任何建议?

Here's a list of my dependencies, let me know if there's anything I need to elaborate on: 这是我的依赖项列表,让我知道是否需要详细说明:

"dependencies": {
    "aws-sdk": "^2.7.10",
    "express": "^4.14.0",
    "request": "^2.79.0",
    "request-promise": "^4.1.1"
  },

You can send post notification using Ajax call. 您可以使用Ajax呼叫发送帖子通知。

 $.ajax({
        url: "/your/controller",
        data: myData,
        dataType: "json",
        cache: false,
    }).success(function (result) {
        // Do something with responce
    });

So, next step is to make route on node.js server side for incoming requests. 因此,下一步是在node.js服务器端建立路由以接收传入请求。 For example: 例如:

var express = require('express');
var app = express();
var router = express.Router();

app.use('/your/controller', {

    router.post('/', function (req, res, next){
        var requestedData = req.body.myData;

        res.status(200).end();    
    });
});

Hope this help. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何发送带有 Node.js 字符串的 post 请求? - How do I send a post request with a string in Node.js? 如何将数据作为响应从Node.js服务器发送到AJAX客户端? - How do I send data as a response from Node.js server to AJAX client? 如何使用 fetch 将 JSON 数据发送到 node.js 服务器? - How do I send JSON data to node.js server using fetch? 如何将 React Draft Wysiwyg 数据从 reactjs 发送回 node.js 服务器? - How do I send React Draft Wysiwyg data back to node.js server from reactjs? 如何在客户端服务器上运行我的 node.js 应用程序而不与他们共享代码库? - How do I run my node.js application on a client's server without sharing the codebase with them? 如何在Node.js中获取输入POST数据? - How do I get input POST data in Node.js? 如何使用node.js获取POST数据? - How do I get POST data with node.js? 如何将C ++应用程序与node.js服务器连接以获取JSON数据? - How can I connect my C++ application with an node.js server to get JSON data? 如何缩小node.js应用程序? (服务器端node.js,而不是客户端javascript) - How to minify a node.js application? (Server side node.js, not client side javascript) 如何设计Node.js API,以便也可以从服务器端使用它? - How do I design my Node.js API so that I can also consume it from the server side?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM