Skip to content

Commit

Permalink
Drop unneeded “else” after “throw” in “async and await” how-to (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
denik1981 committed Mar 14, 2021
1 parent 91ba83a commit 9d64d82
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions files/en-us/learn/javascript/asynchronous/async_await/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ <h2 id="Rewriting_promise_code_with_asyncawait">Rewriting promise code with asyn
.then(response =&gt; {
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  } else {
    return response.blob();
  }
  }
  return response.blob();
})
.then(myBlob =&gt; {
let objectURL = URL.createObjectURL(myBlob);
Expand All @@ -123,13 +122,14 @@ <h2 id="Rewriting_promise_code_with_asyncawait">Rewriting promise code with asyn

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
} else {
let myBlob = await response.blob();
}

let myBlob = await response.blob();

let objectURL = URL.createObjectURL(myBlob);
let image = document.createElement('img');
image.src = objectURL;
document.body.appendChild(image);
let objectURL = URL.createObjectURL(myBlob);
let image = document.createElement('img');
image.src = objectURL;
document.body.appendChild(image);
}
}

Expand All @@ -146,9 +146,9 @@ <h2 id="Rewriting_promise_code_with_asyncawait">Rewriting promise code with asyn
let response = await fetch('coffee.jpg');
if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  } else {
    return await response.blob();
  }
  }
  return await response.blob();

}

myFetch().then((blob) =&gt; {
Expand Down Expand Up @@ -188,13 +188,13 @@ <h3 id="Adding_error_handling">Adding error handling</h3>

if (!response.ok) {
  throw new Error(`HTTP error! status: ${response.status}`);
} else {
  let myBlob = await response.blob();
  let objectURL = URL.createObjectURL(myBlob);
  let image = document.createElement('img');
  image.src = objectURL;
  document.body.appendChild(image);
}
}
  let myBlob = await response.blob();
  let objectURL = URL.createObjectURL(myBlob);
  let image = document.createElement('img');
  image.src = objectURL;
  document.body.appendChild(image);

} catch(e) {
console.log(e);
}
Expand All @@ -210,9 +210,9 @@ <h3 id="Adding_error_handling">Adding error handling</h3>
let response = await fetch('coffee.jpg');
if (!response.ok) {
  throw new Error(`HTTP error! status: ${response.status}`);
} else {
  return await response.blob();
}
  return await response.blob();

}

myFetch().then((blob) =&gt; {
Expand Down Expand Up @@ -247,15 +247,15 @@ <h2 id="Awaiting_a_Promise.all">Awaiting a Promise.all()</h2>

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
} else {
if(type === 'blob') {
content = await response.blob();
} else if(type === 'text') {
content = await response.text();
}

return content;
}
if(type === 'blob') {
content = await response.blob();
} else if(type === 'text') {
content = await response.text();
}

return content;


}

Expand Down

0 comments on commit 9d64d82

Please sign in to comment.