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

Dynamic .get() URLs #42

Closed
jdufour opened this issue Aug 19, 2015 · 4 comments
Closed

Dynamic .get() URLs #42

jdufour opened this issue Aug 19, 2015 · 4 comments

Comments

@jdufour
Copy link

jdufour commented Aug 19, 2015

I'm failing a bit at getting data to pass into the .get, the url isn't directly encoded from the web page but rather a constructed url using an id number. I tried using data to construct it, but wasn't able to pass it to the get command. Thoughts?

.get(init)
.follow('div.name > a')
.set({
    'someNo': 'tr.no'
})
.data(function(data) {
    data.url = 'http://somesite'+ data.someNo + 'moreurl'
})
.get(data.url)

Which fails because no data.url is undefined.

How might I go about passing data to the .get?

Best Regards

@rchipka
Copy link
Owner

rchipka commented Oct 7, 2015

The next version will accept a callback function as the first argument for .get. So you will be able to do this:

.get(function(context, data) {
    return data.url
})
...

@rchipka
Copy link
Owner

rchipka commented Oct 28, 2015

The solution mentioned above is supported in the latest version.

@rchipka rchipka closed this as completed Oct 28, 2015
@jdufour
Copy link
Author

jdufour commented Oct 29, 2015

Thanks! Much appreciated!

@rchipka rchipka reopened this Oct 29, 2015
@rchipka rchipka changed the title Question About Passing Data to .get Dynamic .get() URLs Oct 29, 2015
@rchipka
Copy link
Owner

rchipka commented Oct 30, 2015

The latest commits supports a callback function as the URL argument as well as a formatted string.

.get(init)
.follow('div.name > a')
.set({
    'someNo': 'tr.no'
})
.get('http://somesite.com/%{someNo}/moreurl')

@rchipka rchipka closed this as completed Oct 30, 2015
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