1(async () => {
2 const rawResponse = await fetch('https://httpbin.org/post', {
3 method: 'POST',
4 headers: {
5 'Accept': 'application/json',
6 'Content-Type': 'application/json'
7 },
8 body: JSON.stringify({a: 1, b: 'Textual content'})
9 });
10 const content = await rawResponse.json();
11
12 console.log(content);
13})();
1var myHeaders = new Headers();
2
3var myInit = { method: 'POST',
4 headers: myHeaders,
5 mode: 'cors',
6 cache: 'default' };
7
8fetch('flowers.jpg',myInit)
9.then(function(response) {
10 return response.blob();
11})
12.then(function(myBlob) {
13 var objectURL = URL.createObjectURL(myBlob);
14 myImage.src = objectURL;
15});
16
17