[英]Accessing Azure SQL database for my react web application
I've deployed an Azure web application with a SQL database.我已经部署了一个 Azure web 应用程序和一个 SQL 数据库。 For the frontend I use ReactJS.对于前端,我使用 ReactJS。 I've successfully connected to the SQL database with NodeJS, and I can execute queries and reach the data in the sql database.我已经使用 NodeJS 成功连接到 SQL 数据库,并且可以执行查询并访问 sql 数据库中的数据。 So at this point I want to use that data in the frontend.所以此时我想在前端使用该数据。 I can only see the data in my terminal, I guess I have a missing piece for the communication between the server side and the client side.我只能在终端中看到数据,我想我在服务器端和客户端之间的通信方面缺少了一块。 So my question is how I can get the data to the frontend?所以我的问题是如何将数据发送到前端?
Happy for any suggestions.很高兴有任何建议。
You must create a endpoint that allow your frontend make a http request to your node app.您必须创建一个端点,允许您的前端向您的节点应用程序发出 http 请求。 Your node app should get the data from the DB and return as response of the request.您的节点应用程序应该从数据库中获取数据并作为请求的响应返回。 Then your frontend will get the data you want.然后你的前端会得到你想要的数据。
frontend ---http request (ajax, fetch)-->backend node app --query-> database前端---http请求(ajax,fetch)-->后端节点应用--query->数据库
Create a REST API with Node 用节点创建 REST API
Client Tier is your React app (frontend)客户端层是您的 React 应用程序(前端)
Application Tier is your Node App (backend)应用程序层是您的节点应用程序(后端)
Database Tier the name talks for herself:D数据库层这个名字不言自明:D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.