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

Bug: "Select Catagory" as a input.value causes a waste of a fetch request. #5

Open
MohamedBakoush opened this issue Jun 26, 2022 · 0 comments

Comments

@MohamedBakoush
Copy link

For getApis() at app.js the input.value isn't checked to see if a valid category is selected causing the system to waste fetch requests if an invalid category was selected.

Apihouse/app.js

Lines 20 to 26 in 4b3243b

async function getApis() {
apiList.innerHTML = "";
count.textContent = "";
let category = input.value;
renderLoader();
fetch(`https://api.publicapis.org/entries?category=${category}&https=true`)

To Reproduce
Steps to reproduce the behaviour:

  1. Selected "Select Catagory" as a Catagory
  2. Click "show API's"
  3. See "Sorry, Something went wrong !" error

Potential Solution

A simple solution would be to put a validity checker above renderLoader() by exiting getApis() function if a category == "Select Category". As "Select Category" is the only available invalid selectable category from the current option's, making a simple if statement all that's needed to fix this bug.

if (category === "Select Category") return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant