Skip to content

Perform multiple simultaneous ajax calls and zip the results is not working #44

@augusto-altman

Description

@augusto-altman

I'm trying to perform multiple simultaneous ajax request to a REST api and get a stream that emits a value with a data structure containing the data retrieved by all the responses altogether. For this I'm using zip but I'm getting the following exception from Bacon.js:
Uncaught Error: At least one EventStream required

As an example, below there is a simplified version of my code:

let profileStreams = [];
let profiles = {
  someURL: {
    href: 'www.google.com'
  },
  someOtherURL: {
    href: 'github.com'
  },
  yetAnotherURL: {
    href: 'twitter.com'
  }
};

for (let index in profiles) {
  profileStreams.push(
    b$.ajax({
      url: profiles[index].href
    }).map((profileObject) => {
      return {
        owner: index,
        profile: profileObject
      };
    })
  );
}

let allUrlsRetrievedAsArray = Bacon.zipAsArray(profileStreams);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions