怎么样用js代码发get请求?
不建议使用XMLHttpRequest,我们不妨用fetch。
fetch与xhr相比有很多优势,比如:可以用在service worker中...
来个fetch的示例:
fetch("url") .then(res => res.json()) .then(data => console.log("有数据了:", data))
朱绪2021-12-09331JavaScript
怎么样用js代码发get请求?
不建议使用XMLHttpRequest,我们不妨用fetch。
fetch与xhr相比有很多优势,比如:可以用在service worker中...
来个fetch的示例:
fetch("url") .then(res => res.json()) .then(data => console.log("有数据了:", data))