Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between query string, formData and request payload

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the difference between query string, formData and request payload". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between query string, formData and request payload".

Why?

Because the data formats of the front and back ends are different. That is, the data format transmitted by the front end to the back end does not match the way the back end receives the data. The following is mainly about the front end, that is, only focus on the data format at the time of the request.

1. Transfer data in the address bar

1), query string Parameters:

When the request method is get, the browser will pass the data in the way of query string, that is, query string Parameters

Rules for query strings: request parameters are passed using a URL address and "question mark"-separate url from request parameters with a question mark.

The format of the request parameters: reflected in the way of key-value pairs, multiple key-value pairs are separated by &.

Suppose: the request address is newsList.php. The request parameters are pageIndex and pageCount.

Then, the format of the request is: newsList.php?pageIndex=1&pageCount=10

As shown in the figure below, the request method is get, and what you can see in the network of the chrome browser is: query string Parameters

2. Transfer data in the request body

When the request method is not get (mostly post or put), the requested data is not on the url, but in the request body. The English word of the request body is: request payload. But chrome browsers make a distinction for different content-type, namely formData and request payload.

1), formData

When the value of content-type is "application/x-www-form-urlencoded" or multipart/form-data; boundary=----WebKitFormBoundaryBoMA1XQDUpwpxKQg, the data is passed in the format of formData

2), request payload

When the value of content-type is "text/plain" or "application/json", the data is passed in the format of request payload

Attached: default data format:

1. In traditional ajax requests, Content-Type defaults to the "text" type.

2. When traditional form submits, Content-Type defaults to "Form" type (application/x-www-form-urlencoded)

3. When axios passes a string, Content-Type defaults to "Form" type (application/x-www-form-urlencoded)

4. When axios passes objects, Content-Type defaults to "JSON" type ((application/json))

Thank you for your reading, the above is the content of "what is the difference between query string, formData and request payload". After the study of this article, I believe you have a deeper understanding of what is the difference between query string, formData and request payload. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report