Javascript 如何在axios Reactjs中发送查询参数
这是我的邮递员请求:Javascript 如何在axios Reactjs中发送查询参数,javascript,reactjs,typescript,post,axios,Javascript,Reactjs,Typescript,Post,Axios,这是我的邮递员请求: http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking 有谁能帮我通过axios进行post通话吗。productOne和productTwo是查询参数,1234是路径参数,我想你应该先看一下文档: 发件人: 您给定的URL看起来像get方法: http/localhost:8080/sample-market/m
http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking
有谁能帮我通过axios进行post通话吗。productOne和productTwo是查询参数,1234是路径参数,我想你应该先看一下文档: 发件人: 您给定的URL看起来像get方法:
http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking
但是如果您仍然想使用POST,那么您可以:
axios.post('http/localhost:8080/sample-market/marketAPI/1234/product/publish', {
productOne: 'testing',
productTwo: 'checking'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
对于GET方法:
axios.get('http/localhost:8080/sample-market/marketAPI/1234/product/publish', {
params: {
productOne: 'testing',
productTwo: 'checking'
}
})
//OR direct
axios.get('http/localhost:8080/sample-market/marketAPI/1234/product/publish?productOne=testing&productTwo=checking')
你的意思是像在字符串中插入变量一样?这能回答你的问题吗?那么,为什么要发布一个答案呢?按照url更新,这样他就可以知道答案了,没有任何其他东西,没有任何东西的情况下发布一个电话是完全好的body@Singh,在这种情况下,您应该使用GET方法,POST word表示您将要发布,GET表示获取数据。好的,请您解释一下,查询参数的需要是什么?我已经给出了一个API,它有查询参数和一个post调用!该帖子有一个带有两个查询参数的空正文