OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
3 <title>request-body-blob-iframe</title> | 3 <title>request-body-blob-iframe</title> |
4 <body></body> | 4 <body></body> |
5 <script> | 5 <script> |
6 var blob = new Blob(['it\'s me the blob', | 6 var blob = new Blob(['it\'s me the blob', |
7 'and more blob!']); | 7 'and more blob!']); |
8 fetch('simple.html?post-with-blob-body', | 8 fetch('simple.html?post-with-blob-body', |
9 { method: 'POST', body: blob }) | 9 { method: 'POST', body: blob }) |
10 .then(resp => { | 10 .then(resp => { |
11 if (!resp.ok) | 11 if (!resp.ok) |
12 return Promise.reject('bad response: ' + resp.status); | 12 return Promise.reject('bad response: ' + resp.status); |
13 return resp.text() | 13 return resp.text() |
14 }) | 14 }) |
15 .then(text => parent.done(text)) | 15 .then(text => parent.done(text)) |
16 .catch(error => { | 16 .catch(error => { |
17 var reason = error.message || error.name || error; | 17 var reason = error.message || error.name || error; |
18 parent.done('error: ' + reason); | 18 parent.done('error: ' + reason); |
19 }); | 19 }); |
20 </script> | 20 </script> |
OLD | NEW |