Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request example of .continue #12

Open
nrbunn opened this issue Jul 18, 2017 · 1 comment
Open

Request example of .continue #12

nrbunn opened this issue Jul 18, 2017 · 1 comment

Comments

@nrbunn
Copy link

nrbunn commented Jul 18, 2017

I haven't been able to find a way to mimic the below using promises. Can someone help me out if its even possible?

traverson
.from(rootUrl)
.follow('link1', 'link2')
.getResource(function(err, firstResource, traversal) {
  if (err) { return done(err); }
  // do something with the first resource, maybe decide where to go from here.
  traversal
  .continue()
  .follow('link3', 'link3')
  .getResource(function(err, secondResource) {
    if (err) { return done(err); }
    // do something with the second resource
  });
});
@xin-nie
Copy link
Member

xin-nie commented Aug 3, 2017

@SinBle Sorry for the late reply, I had some life changes recently. It's definitely possible to use continue, just need to add resultWithTraversal() before the promise resolve:

traverson
  .from(rootUrl)
  .follow('link1', 'link2')
  .getResource()
  .resultWithTraversal()
  .then(({ result, traversal }) =>
     traversal
       .continue()
       .follow('link3', 'link3')
        .getResource()
        .result
        .then(...)
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants