[英]How to convert cURL request to axios
I want to use the below cURL
command with the axios
.我想将以下
cURL
命令与axios
一起使用。 How I can do that?我该怎么做?
curl -XPOST -d 'url=https%3A%2F%2Fgoogle.com%2F' 'https://goolnk.com/api/v1/shorten'
I have tried in this way but seems to be incorrect:我试过这种方式,但似乎不正确:
axios.post("https://goolnk.com/api/v1/shorten", {
url: "https%3A%2F%2Fgoogle.com%2F"
}).then(function (response) {
console.log(response)
})
You almost made it, but url
key should just be a link string, without any special symbols.你几乎成功了,但
url
键应该只是一个链接字符串,没有任何特殊符号。
axios
.post('https://goolnk.com/api/v1/shorten', { url: 'https://google.com' })
.then((res) => {
console.log(res.data);
});
Please, don't post code as images in the future, instead insert it as code block in the text.请不要在以后将代码作为图像发布,而是将其作为代码块插入文本中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.