简体   繁体   English

为我的反应 web 应用程序访问 Azure SQL 数据库

[英]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

Using Fetch 使用 Fetch

在此处输入图像描述

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.

相关问题 数据库在从SQL视图访问数据时在MVC Web应用程序中抛出InvalidOperationException状态500 - Database is throwing an InvalidOperationException status of 500 in a MVC Web Application while accessing data from an SQL View 从Cocoa应用程序访问SQL数据库 - Accessing SQL database from Cocoa application 从Web应用程序连接Azure SQL - Azure SQL connect from Web Application 如何使用SQL数据库设置Azure Web服务 - How to setup Azure web service with sql database 如何在另一台计算机上运行我的asp.net Web应用程序以及我的SQL数据库 - How to run my asp.net web application on another computer along with my SQL database 将ASP.Net应用程序从Web连接到计算机上的sql数据库 - Connect ASP.Net application from web to my sql database on my computer azure web应用程序和azure sql数据库之间的高延迟 - High latency between the azure web app and azure sql database 'sa' 用户正在“ping”我的 Azure SQL 数据库 - 'sa' user is "pinging" my Azure SQL Database 如何从桌面应用程序中Web服务器上托管的SQL Server数据库中检索数据? - How I Retrieve Data from SQL Server Database hosted on a Web Server in my desktop application? Web应用程序的SQL Server数据库隔离级别 - SQL server database isolation level for web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM