Getting “Object not defined” even when it's loaded before the current script

Getting “Object not defined” even when it's loaded before the current script

I have two JS files. One defines a const object called WebRequest and the other uses the WebRequest object.

The file with WebRequest are loaded before the file that uses the object, but I get:
ReferenceError: WebRequest is not defined

Html:
  
  1. <script crossorigin="anonymous" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" src="https://code.jquery.com/jquery-3.4.1.js" type="application/JAVASCRIPT"></script>
  2. <script src="/SCRIPT/WebRequest.js" type="application/JAVASCRIPT"></script>
  3. <script src="/SCRIPT/Identity.Index.js" type="application/JAVASCRIPT"></script>

WebRequest.js:
  
  1. $(document).ready(() => {
  2. class RequestResult {
  3. constructor(response) {
  4. this.resp = response;
  5. }
  6. response() {
  7. return this.resp;
  8. }
  9. success() {
  10. return this.resp.ok;
  11. }
  12. status() {
  13. return this.resp.status;
  14. }
  15. statusText() {
  16. return this.resp.statusText;
  17. }
  18. }
  19. const WebRequest = async (controller = "API", action, query = {}, data = {}, method = RequestMethods.POST, mode = RequestModes.SameOrigin, creds = RequestCredentials.SameOrigin, headers = {
  20. "Content-Type": "application/json",
  21. "Accept": "application/json"
  22. }) => {
  23. ...
  24. };
  25. });

Identity.Index.js:
     
  1. $(document).ready(() => {     var _searchBox = $("#searchBox");     var _searchTimeout = null;
  2.  _searchBox.keyup(() => {         clearTimeout(_searchTimeout);         _searchTimeout = setTimeout(doSearch, 500);     });
  3.  $(".search-submit").click(doSearch);     $(".result-wrap > .close-wrap > .icon").click(() => {         $(".result-wrap").hide();         _searchBox.val("");         _searchBox.focus();     });
  4.        async function doSearch() {         var str = _searchBox.val();
  5.  if (str.length > 0) {             $(".search-no-found").hide();             $(".working").show();             $(".search-result").hide();             $(".site-wrap").hide();
  6.  var result = await WebRequest("Identity", "Search", null, { text: str });         }         else {             $(".result-wrap").hide();         }     } });

Any ideas??

--------------
Just so we're clear - you need a hero?