@@ -2,7 +2,7 @@ import utils from "../utils";
22import WeFetch from "./Wefetch" ;
33import { UPLOAD_CONTENT_TYPE , DOWNLOAD_CONTENT_TYPE } from '../defaults'
44import platform from "./platform" ;
5-
5+ import promisify from "./promisify" ;
66[ 'options' , 'get' , 'head' , 'post' , 'put' , 'delete' , 'trace' , 'connect' , 'postJson' ] . forEach ( function ( method ) {
77 WeFetch . prototype [ method ] = function ( url , config ) {
88 return this . request ( utils . merge ( config || { } , {
@@ -14,8 +14,6 @@ import platform from "./platform";
1414WeFetch . prototype . download = function ( url , config ) {
1515 // init
1616 config = config || { } ;
17- config . createRequest = platform . getDownload ( ) ;
18-
1917 // check user is input header param
2018 if ( config . header ) {
2119 config . header [ 'Content-Type' ] = config . header [ 'Content-Type' ] || DOWNLOAD_CONTENT_TYPE
@@ -25,18 +23,18 @@ WeFetch.prototype.download = function (url, config) {
2523
2624 // wf.download({}) support
2725 if ( utils . type . isObject ( url ) ) {
28- return this . request ( utils . merge ( config , url ) )
26+ return this . request ( utils . merge ( config , url , { method : 'download' } ) )
2927 }
3028 // default
3129 return this . request ( utils . merge ( config , {
32- url : url
30+ url : url ,
31+ method : 'download'
3332 } ) )
3433} ;
3534
3635WeFetch . prototype . upload = function ( url , config ) {
3736 // init
3837 config = config || { } ;
39- config . createRequest = platform . getUpload ( ) ;
4038 // check user is input header param
4139 if ( config . header ) {
4240 config . header [ 'Content-Type' ] = config . header [ 'Content-Type' ] || UPLOAD_CONTENT_TYPE ;
@@ -46,9 +44,13 @@ WeFetch.prototype.upload = function (url, config) {
4644
4745 // upload({}) support
4846 if ( utils . type . isObject ( url ) ) {
49- return this . request ( config , url )
47+ return this . request ( config , url , { method : 'upload' } )
5048 }
5149 return this . request ( utils . merge ( config , {
52- url : url
50+ url : url ,
51+ method : 'upload'
5352 } ) )
5453} ;
54+ WeFetch . prototype . login = function ( ) {
55+ return promisify ( platform . getPlatform ( ) . login ) ( ) ;
56+ } ;
0 commit comments