import utils from "../utils/index";

export function Net(paroms) {
  let url = paroms.url,
    data = paroms.data || {};
  if (paroms.method.toLowerCase() === "get") url = utils.decodeURL(url, data);
  if (window.fetch)
    return new Promise((resolve, reject)=>{
        fetch(url, {
            method: paroms.method,
            // mode: 'no-cors',
            data,
          }).then(r => {
              return r.json()
          }).then(r=>{
            resolve(r)
          }).catch(err=>{
              reject(err)
          });
    })
}
