简体   繁体   English

从前端 web 服务器调用 API 服务器

[英]Making calls to API Servers from a frontend web server

I'm a little confused about frontend servers making calls to API Servers.我对调用 API 服务器的前端服务器有点困惑。

When I access a frontend site, the browser connects to the frontend server and the html files are downloaded and copied into my browser.当我访问前端站点时,浏览器连接到前端服务器,html 文件被下载并复制到我的浏览器中。 So when i make an API call, is the call being made from frontend web server or from the browser?因此,当我进行 API 调用时,该调用是从前端 web 服务器还是从浏览器进行的?

There is no such thing as a frontend web server.没有前端 web 服务器之类的东西。 When you connect to a website on the web, your computer connects to a web server, which then sends the requested files back to your browser.当您连接到 web 上的网站时,您的计算机会连接到 web 服务器,然后将请求的文件发送回您的浏览器。

When you make an API call, the same thing is essentially happening.当您进行 API 调用时,基本上会发生同样的事情。 You are either requesting or sending data to a server.您正在向服务器请求或发送数据。 The question as to where the call originates from depends on what you are using to call said server.关于呼叫来自何处的问题取决于您用来呼叫所述服务器的内容。 If it's a web browser, then yeah it's the browser who's responsible for sending the request如果它是 web 浏览器,那么是的,它是负责发送请求的浏览器

I think you might be referring to the front-end framework like Vue, Angular, etc. If you use Vue for example, you can make API call from there (the front-end) using a specified package like axios. I think you might be referring to the front-end framework like Vue, Angular, etc. If you use Vue for example, you can make API call from there (the front-end) using a specified package like axios.

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

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