Browser POST method call interface

Now most of them are front-end and back-end separation projects. This development uses session to store user information in the back-end. It happens that the interface call method is POST call. After using the browser to log in successfully, it is not feasible to use postman call, so we still have to Use the browser to call, but the default method of entering the interface address in the browser address bar is the get request method, and finally found the solution, record it here

We use the browser console to achieve our needs

The code is as follows: where method is the request method name, headers is the request header, and body is the request body

fetch(new Request('https://blog.csdn.net/weixin_43650254',{
    
    
    method:'POST',
    headers: {
    
    'Content-Type': 'application/json'},
    body:'{\"param\":\"value\"}'
})).then(response => response.json())
.then(data => console.log(data));

Use the browser developer function (F12) to open the console and enter this statement to execute the request and return the response.

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43650254/article/details/129386877