简体   繁体   English

如何将数据从Electron.js应用程序发送到远程服务器/数据库

[英]How to send data from an Electron.js app to a remote server/db

As the title states, I'm having trouble finding a way to send data from an electron.js app to a remote db/server. 如标题所示,我很难找到一种方法将数据从electron.js应用程序发送到远程数据库/服务器。

I can use mysql to connect directly with a database but it doesn't strike me as a secure thing to do. 我可以使用mysql直接与数据库连接,但是这样做并不安全。 I would like to send the data, probably a json string, to a php or js file on a server and handle the validation and database access there. 我想将数据(可能是json字符串)发送到服务器上的php或js文件,并在那里进行验证和数据库访问。

I'm very new to working with node.js and electron.js but I'm really excited over the possibilities of it. 我对使用node.js和electron.js非常陌生,但是我对它的可能性感到非常兴奋。

Have you got a working web server? 您有可用的网络服务器吗?

I'd recommend express - it's fairly simple to get started. 我建议快递 -入门非常简单。 You could define a route that you could post your data to, and then that would in turn add it to the database. 您可以定义一条路由,将数据发布到该路由,然后将其添加到数据库中。

You can make a standard AJAX request from the browserWindow of your Electron app. 您可以从Electron应用程序的browserWindow发出标准AJAX请求。 Please refer to this question: 请参考以下问题:

javascript ajax request without framework 没有框架的javascript ajax请求

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM