I think you don't have to use URLSearchParams as a parameter, simply use readTaskId const readTaskForm = document.querySelector("#task-id-form"); readTaskForm.addEventListener("submit", (e) => { const readTaskId = document.querySelector("#task-id").value; //const params = { id: readTaskId }; // new addition //const urlParams = new URLSearchParams(Object.entries(readTaskId)); fetch("http://localhost:3000/tasks/" + readTaskId, { method: "get", headers: { Accept: "application/json, text/plain, */*", "Content-Type": "application/json", Authorization: `Bearer` + `${inMemoryToken}` } }) .then((res) => res.json()) .then((res) => { console.log(res); }); }); 这篇关于如何在url中传递参数,并在JavaScript服务器端的NodeJS后端使用冒号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 05:48