如下所示的代码示例中,使用 Axios 发送 GET 请求时将 URL 的末尾斜线去掉即可解决该问题。
import axios from 'axios';
axios.get('https://example.com/api/') // 发送 GET 请求,注意 URL 中末尾的斜线
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
axios.get('https://example.com/api') // 发送 GET 请求,注意 URL 中末尾的斜线已去掉
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});