Angular 5-接收POST请求 [英] Angular 5 - Receive POST requests

查看:92
本文介绍了Angular 5-接收POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景::我的角度页面应该正在接收来自SpringBoot API的带有JSON数据的 POST 请求.

Scenario: My angular page should be receiving a POST request with JSON data from SpringBoot API.

将此作为工作示例进行考虑:当客户端单击某个有角网页上的登录名时,登录信息将通过JSON发送到SpringBoot,在此它将验证用户,如果返回true,则然后,相同的JSON将以 POST 的形式转发回网页,然后将其捕获并进行处理(例如显示).

Consider this as a work example: When client clicks on login on an angular webpage, the login info would be sent through JSON to SpringBoot where it will validate the user,if it returns true, the same JSON would then be forwarded back to webpage as POST, where it will be captured and then worked on(displayed for example).

现在,根据此链接,据说POST请求无法在Angular上接收,但需要Express来实现.是真的吗还是有其他方法可以使用Angular从API接收 POST 请求?我从很多天开始一直在仔细研究这个问题,但没有发现任何相关内容可以确认这一点,因此需要关闭.

Now, as per this link, it is said that POST requests cannot be received on Angular but need Express for the same. Is it true? or is there any other way to receive POST requests from API using Angular? I'm googling on this from many days and haven't found anything relevant that confirms this and needed a closure.

推荐答案

Angular是一个用于在浏览器(这是HTTP client 类型)中提供用户界面的库.

Angular is a library for providing a user interface in a browser (which is a type of HTTP client).

要侦听HTTP请求,您需要HTTP服务器(例如Apache HTTPD,Lighttpd,NGINX,使用Node.js + Express构建的内容等).

To listen for an HTTP request you need an HTTP server (such as Apache HTTPD, Lighttpd, NGINX, something built with Node.js+Express, etc, etc, etc).

还有其他方法可以使用Angular从API接收POST请求吗?

is there any other way to receive POST requests from API using Angular?

应该从SpringBoot API接收带有JSON数据的POST请求.

should be receiving a POST request with JSON data from SpringBoot API.

Spring是用于运行Web服务的Java框架.

Spring is a Java framework for running a webservice.

通常,它接收 HTTP请求并进行HTTP响应.

Typically it receives HTTP requests and makes HTTP responses.

尽管您可以从中发出HTTP请求(即,当客户端向Spring API发出HTTP请求时,Spring API随后向另一个Web服务发出HTTP请求,并使用响应中的数据来构造自己的响应)原始请求)…

While you could make HTTP requests from it (i.e. when a client makes an HTTP request to a Spring API, the Spring API then makes an HTTP request to another web service and uses the data in the response to construct its own response to the original request)…

…听起来您手杖的一端错了,真的需要从 Angular Spring发出HTTP POST请求,然后阅读HTTP 响应.

… it sounds like you have the wrong end of the stick and really need to make an HTTP POST request from Angular to Spring and then read the HTTP response in Angular.

Ajax .

这篇关于Angular 5-接收POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆