Ben Hsieh 8 年之前
父節點
當前提交
42b13a5877
共有 2 個檔案被更改,包括 5 行新增5 行删除
  1. 1
    1
      src/index.js
  2. 4
    4
      test/tests.js

+ 1
- 1
src/index.js 查看文件

25
     let [method, url, headers, body] = [...args]
25
     let [method, url, headers, body] = [...args]
26
     let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
26
     let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
27
 
27
 
28
-    RNFetchBlob[nativeMethodName](method, url, headers, body, (err, ...data) => {
28
+    RNFetchBlob[nativeMethodName](method, url, headers || {}, body, (err, ...data) => {
29
       if(err)
29
       if(err)
30
         reject(new Error(err, ...data))
30
         reject(new Error(err, ...data))
31
       else
31
       else

+ 4
- 4
test/tests.js 查看文件

15
 
15
 
16
 const FILENAME = `${Platform.OS}-0.4.0-${Date.now()}.png`
16
 const FILENAME = `${Platform.OS}-0.4.0-${Date.now()}.png`
17
 // paste your test config here
17
 // paste your test config here
18
-const TEST_SERVER_URL = 'http://your-local-ip:8123'
19
-const DROPBOX_TOKEN = 'drop-box-api-token'
18
+const TEST_SERVER_URL = 'http://192.168.17.207:8123'
19
+const DROPBOX_TOKEN = 'fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz'
20
 
20
 
21
 const ctx = new RNTest.TestContext()
21
 const ctx = new RNTest.TestContext()
22
 const Assert = RNTest.Assert
22
 const Assert = RNTest.Assert
88
 
88
 
89
 ctx.describe('Compare uploaded multipart image', async function(report) {
89
 ctx.describe('Compare uploaded multipart image', async function(report) {
90
   // try {
90
   // try {
91
-    let resp = await RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-img.png`, {})
92
-    let resp2 = await RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-text.txt`, {})
91
+    let resp = await RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-img.png`)
92
+    let resp2 = await RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-text.txt`)
93
     console.log(resp)
93
     console.log(resp)
94
     console.log(resp2)
94
     console.log(resp2)
95
     report({
95
     report({