💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
## xhr 请求 * xhr = new XMLHttpRequest() * xhr.open(method, url) * xhr.send(data) * xhr.onreadystatechange ``` function request (method, url, data) { var xhr = new XMLHttpRequest(); const requestMethod = method.toLowerCase() if (requestMethod === 'post') { xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); } xhr.open(method, url); if (requestMethod === 'get') { var query = toQueryString(data) xhr.send(url + '?' + query); } else { xhr.send(data); } xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { return xhr.responseText } } } ``` ## 取消请求 - xhr.abort() ## axios 取消请求 - CancelToken