Note upload applet interface

 

Note upload applet interface

The need for the return of the interface data into JavaScript objects

// JSON.parse () converts the data format into JSON JavaScript object 

JSON.parse (res.data)

  

Official Documents

https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html

 

wx.chooseImage ({ 
    Success (RES) { 
      const = tempFilePaths res.tempFilePaths 
      wx.uploadFile ({ 
        URL: 'https://example.weixin.qq.com/upload', // only exemplary, non-real interface address the interface returned the JSON 
        filePath: tempFilePaths [0], 
        name: 'File', 
        formData: { 
          'User': 'Test' 
        }, 
        Success (RES) { 
          // need to upload JSON.parse because the interface returns a string 
          the console.log (typeof res.data) 
          the let the JSON.parse Data = (res.data) 
          // do something 
        } 
      }) 
    } 
  })

  

 

  

 

Guess you like

Origin www.cnblogs.com/zelzzz/p/11517637.html