我以前从未使用过 encodeURIcomponent ,并且由于某种原因,我正在阅读的文档没有帮助,而且我迄今为止尝试过的方法也没有效果。(还在学习)
我试图在搜索时向我的后端快递服务器发送一个 url,这将返回一个响应。谁能提供一些关于我将如何做到这一点的见解?
这是我的前端:
async function getSample() {
const res = await fetch('http://localhost:3000/lookup/https://google.com');
const data = await res.text();
console.log(data);
}
document.getElementById('button').addEventListener('click', getSample);
我后端的相关部分:
steve.open(req.params.url).then(function(site) {