繁体   English   中英

如何更改发布请求以获取 postman 中的请求?

[英]How to change post request to get request in postman?

我有一个请求,它是之前发布的请求,但我需要更改它以获取请求。

//teamsApi.js
async getTeamsWithPlayers(payload) {
        const response = await this.request('/teams/getPlayers', payload) //post request
        return response
    }

//base.js
import {$api_esports} from '../api'
export class API_BASE_ESPORTS {
    async request(url, payload, config) {
        const response = await $api_esports.post(url, payload, config).then(handleData).catch(handleError)
        return response
    }
}

//api.js
export const $api_esports = axios.create({
    withCredentials: false,
    baseURL: API_ESPORT_URL,
})

我试图向 API_BASE_ESPORTS 添加新请求,但它不起作用(像这样)

export class API_BASE_ESPORTS {
    async request(url, payload, config) {
        const response = await $api_esports.post(url, payload, config).then(handleData).catch(handleError)
        return response
    }
    async getRequest(url) {
        const response = await $api_esports.get(url).then(handleData).catch(handleError)
        return response
    }

}

如果我没有忽略某些事情,axios 不允许带有额外负载的 GET 请求:

https://github.com/axios/axios#request-config (见data属性)。

This means, you'd have to convert your payload into a URL parameter string, append that to the URL you pass to API_BASE_ESPORTS.request and additionally change the $api_esports.post call to $api_esports.get .

暂无
暂无

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

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