💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# RequestTask ### RequestTask > 支持版本 >= 1.4.0 网络请求任务对象 #### 方法 ##### RequestTask.abort() 中断请求任务 #### 示例代码 ``` <pre class="prettyprint"><ol class="linenums"><li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="kwd">const</span><span class="pln"> requestTask </span><span class="pun">=</span><span class="pln"> wx</span><span class="pun">.</span><span class="pln">request</span><span class="pun">({</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> url</span><span class="pun">:</span><span class="pln"> </span><span class="str">'test.php'</span><span class="pun">,</span><span class="pln"> </span><span class="com">//仅为示例,并非真实的接口地址</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> data</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> x</span><span class="pun">:</span><span class="pln"> </span><span class="str">''</span><span class="pln"> </span><span class="pun">,</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> y</span><span class="pun">:</span><span class="pln"> </span><span class="str">''</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="pun">},</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> header</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="str">'content-type'</span><span class="pun">:</span><span class="pln"> </span><span class="str">'application/json'</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="pun">},</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> success </span><span class="pun">(</span><span class="pln">res</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln">res</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="pun">}</span></code></li> <li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pun">})</span></code></li> <li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln">requestTask</span><span class="pun">.</span><span class="pln">abort</span><span class="pun">()</span><span class="pln"> </span><span class="com">// 取消请求任务</span></code></li> </ol> ``` > 原文: <https://developers.weixin.qq.com/minigame/dev/api/network/request/RequestTask.html>