Created
June 30, 2019 15:49
-
-
Save happymishra/8e614f0696f3d1b88bf3e6cf149bc680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<label>Search</label> | |
<!-- Renders an HTML input box --> | |
<input type="text" id="search-box" oninput="makeAPICall()"> | |
<!-- Displays number of time makeAPICall method is called --> | |
<p id='show-api-call-count'></p> | |
</body> | |
<script> | |
function makeAPICall() { | |
var searchBoxDom = document.getElementById('search-box'); | |
var searchBoxValue = searchBoxDom.value; | |
var apiCallCountDom = document.getElementById('show-api-call-count'); | |
var apiCallCount = apiCallCountDom.innerHTML || 0; | |
apiCallCount = parseInt(apiCallCount) + 1; | |
// Updates the number of times makeAPICall method is called | |
apiCallCountDom.innerHTML = apiCallCount; | |
// A very heavy fucntion which hits databases to fetch data | |
apiCall() | |
} | |
function apiCall() { | |
// This represent an API call which makes database hits | |
for(var i = 0; i < 1000000; i++) { | |
} | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment