@DavidMorgade
Posted
Hello Vander, congrats on finishing this challenge! pretty good job with the API_KEY hide on the backend!
You App seems to work good but I can enter any type of value and it keeps loading to infinity, maybe you can add some validation to your input so it only gets valid ip's or domains, you can use a simple regular expression on your function that executes the code, for example this one:
const ipRegex = '^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$'
Also would recommend you to handle the error in the html or maybe displaying an alert()
so a normal user can see when the app is failing and why, you can use a try catch
block in your fetch
function and catch the error, and the display the error if it fails, don't know how it works with axios tho, I have always used the fetch function.
Hope my feedback helps you!, Good job!
Marked as helpful
@vanderms
Posted
@DavidMorgade , hi David thanks for your comment.
Indeed, I didn't test for user invalid input. But instead of writing a regex pattern, I would recommend a library like ip-regex https://www.npmjs.com/package/ip-regex. Because it works with both IPv4 and IPv6.
In axios is about the same thing. In async functions you can use the try-catch pattern, or use the .then .catch pattern with promises.
Thanks!