Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop unneeded “else” after “throw” in “async and await” how-to #3081

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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