QN.fetch('http://www.taobao.com', { body: '', method: 'GET', mode: 'same-origin', dataType: 'text', }) .then(response => { return response.text(); // => 返回一个 `Promise` 对象 }) .then(data => { Modal.alert('success:' + JSON.stringify(data)) }) .catch(error => { Modal.alert('error:' + JSON.stringify(error)) });
QN.fetch('http://www.taobao.com', { method: 'POST', body: 'id=233&t=20161013', mode: 'same-origin', dataType: 'text', }) .then(response => { return response.text(); // => 返回一个 `Promise` 对象 }) .then(data => { Modal.alert('success:' + JSON.stringify(data)) }) .catch(error => { Modal.alert('error:' + JSON.stringify(error)) });
上述代码中body
参数只能是search string形式。QAP-SDK提供了Object to search string的方法,详情请参考toQueryString章节。