request

发送http请求
GET

  1. import { network } from 'waft';
  2. const obj = new JSONObject();
  3. obj.set('url','https://xxx.xxx.com');
  4. obj.set('method','GET');
  5. // obj.set('headers','');
  6. network.request(obj.toString(), (result: JSONObject):void => {
  7. console.log('---> result: ' + result.toString());
  8. });

POST

  1. import { network } from 'waft';
  2. const obj = new JSONObject();
  3. obj.set('url','https://xxx.xxx.com');
  4. obj.set('method','POST'); // 目前只支持GET
  5. const data = new JSONObject();
  6. data.set("name", "xiaoming");
  7. obj.set('data',data);
  8. network.request(obj.toString(), (result: JSONObject):void => {
  9. console.log('---> result: ' + result.toString());
  10. });