如何通过以下代码使用AXIOS提出请求
我面对,拒绝设置不安全的标题“用户代理”问题,同时尝试使用WooCommerce REST API V3提出请求。我想通过使用Axios修改标题来获取请求。那么如何使用Axios下面的此代码进行操作呢?
const woocommerce = new WooCommerceRestApi({
url: process.env.REACT_APP_WP_URL,
consumerKey: process.env.REACT_APP_WP_KEY,
consumerSecret: process.env.REACT_APP_WP_SECRET,
version: 'wc/v3',
axiosConfig: {
headers: {},
},
})
I faced, Refused to set unsafe header "User-Agent" issue while trying to make get request using woocommerce rest api v3. I want to make get request by using axios modifying the header. So How to do this using this code below from axios?
const woocommerce = new WooCommerceRestApi({
url: process.env.REACT_APP_WP_URL,
consumerKey: process.env.REACT_APP_WP_KEY,
consumerSecret: process.env.REACT_APP_WP_SECRET,
version: 'wc/v3',
axiosConfig: {
headers: {},
},
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
“ content-type”添加:“ application/json; charset = utf-8”
so:Try adding
"Content-Type": "application/json;charset=UTF-8"
to the headers like so: