Is there a way to create a singular asynchronous function that can retrieve data from multiple sources and provide

I'm currently working on an async function that fetches data from multiple sources, waits for all requests to complete, and then returns the JSON results as an array. Here is what I have so far:

file1.js

const searchResults = await Api.search(searchText);

api.js

async function search(searchText) {
    return util.executeFetchAll([
        `/searchA/${searchText}`,
        `/searchB/${searchText}`,
        `/searchC/${searchText}`
    ]);
}

util.js

async function executeFetchAll(urls) {
    const promises = urls.map(url => fetch(url));
    const responses = await Promise.all(promises);

    debugger;
}

As I pause the execution at the debugger and inspect responses using Chrome's developer tools, I can see that it correctly returns an array of 3 Response objects. However, when I try to inspect responses[0].json(), it oddly displays a Promise {<pending>} object in the console.

What could be causing this issue? I thought that by using Promise.all, all promises should be resolved before reaching the debugger line. Why then is the json() method returning a pending Promise object?

Any insights would be greatly appreciated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the absence of any displayed content in FirBug when typing in the Google Search box?

Many websites with a suggestion box feature utilize AJAX requests to communicate with the server and receive responses. I attempted to intercept the requests made by the Google search box, but the FireBug console did not display anything. However, when us ...

Executing AngularJS Accordion event on a webpage

Hello, I am new to using AngularJS and I am currently working on implementing an accordion feature. The accordion is used to display a list of channels on the site. However, I am encountering an issue with the implementation. I want the accordion to be hi ...

Having trouble activating the Samsung Tizen TV through the designated APIs

I currently have a Tizen Application for managing TV Operations such as Volume Controls and Power On/Off. I have implemented the use of b2bapis for Power Off functionalities, but I am struggling to locate comprehensive documentation on the same. The code s ...

Refreshing the form fields and storing the information using AngularJS

I have successfully implemented a basic form using AngularJS. The issue I am facing is that even after the user enters their details and submits the form, the values remain in the input fields. My goal is to store the details of multiple fields in the con ...

The length of the HTTP response in Angular is not defined

Currently, I am utilizing Angular in conjunction with jQuery Mobile to develop multiple pages, but I have encountered an obstacle when using the $http service to connect to my JSON requests. While populating a few arrays with functions and successfully ret ...

Tips for clearing a material-ui search input field with the help of a button

Currently, I am working on a tutorial that involves implementing react material-ui tables along with a search input textfield. I am attempting to enhance this by adding a button that not only resets the table report but also clears the search input textfie ...

Is jQuery Mobile Autocomplete's search feature activated after typing 3 letters?

Hello there, I am in the process of creating a website and have implemented an autocomplete field. However, I am facing an issue due to having over 1000 <li> elements within the <ul>, making it slow especially on mobile devices. I would like t ...

Tips for adjusting the default response format of Drupal services to JSON

Currently, I am utilizing Drupal services in conjunction with a REST server to offer an API. In the past, I only dealt with one type of response, JSON, so there was no need to append ".json" to the URL. However, a new formatter has been introduced - XML ...

Show the "Splash" picture, then switch to a newly uploaded image and show it for a set amount of time

I am in the process of developing an HTML/JavaScript page that will showcase a splash image (splash.jpg) until it gets replaced by another image file called latest.jpg. Once this latest.jpg is displayed, I want it to remain on the screen for 90 seconds bef ...

Tips for converting a JSON Object into an ArrayList in an Android application

I'm facing challenges in figuring out how to parse this JSONObject using Java: {"market_cap":[[1518987267000,183700781183], [1518987567000,183687424480], [1518987868000,183687424480], . . ...

Combining Two DIVS Side by Side

Hey there, I am working on a timeline using two divs within a table cell. My goal is to have these divs overlap instead of appearing one below the other. The position attribute for all the DIVs inside the cell must remain unchanged due to the drag/drop fu ...

What makes this effective in JavaScript?

While working on a project, I encountered the task of comparing coordinates in two arrays at the same index to see if they are identical. There are various methods to achieve this, but one particular approach piqued my interest. Why does it yield the expec ...

Error in form action when generated through an ajax partial in Ruby

I am facing an issue with a form that is loaded via an ajax partial. The problem arises when the form loads through ajax as it targets the wrong controller/url instead of the intended one. Despite my efforts to set the target controller correctly, it keeps ...

Validating Dropdowns in React: An Essential Guide

I am in the process of developing a React-based application and incorporating Yup for validation. However, I am encountering a Cyclic Dependency error during the validation process. Description: Users will be presented with two dropdown lists of colors, v ...

Transmitting a client-side JavaScript function to the server for processing the database response and generating a downloadable CSV file

I need to create CSV reports for a series of queries in my project. In the backend, I have a general POST request handler in nodejs/express that accepts a JSON object structured like this: { "converter": <converter function>, "fields": < ...

Switching from JavaScript to TypeScript resulted in React context not being located in its respective file

I previously had my context and context provider set up in a file, and everything was working perfectly. However, I recently decided to convert all of my files to TypeScript, including this one. Unfortunately, I've encountered a strange issue that I c ...

Is it considered secure to encase a function within jQuery's removeClass()?

I'm currently developing a unique slider that includes a dynamic video element. With each slide transition, a new video is added to the DOM while the previous one is removed. To achieve this effect, I am utilizing CSS transitions along with a specific ...

Adjusting the size of the snap increments

When using gridstack, I have the ability to resize my widgets. However, I've noticed that when dragging on the widgets' handles, they snap to specific sizes, which seems to be a fixed amount. If I wanted to set the widget's size to something ...

Issue: Encounter an Error with Status Code 401 using Axios in React.js

For my login page, I am utilizing a combination of Laravel API and ReactJS frontend. In my ReactJS code, I am using Axios to handle the parsing of the username (email) and password. The login API endpoint is specified as http://127.0.0.1:8000/api/login, wh ...

The success function is failing to display the Ajax response

Is there a way to correctly display the ajax response of my code? I noticed that when using async=true, only the last value of yy is shown. However, I want to display it for all values from 0 to a. Interestingly, everything works fine when using async=fa ...