Automatic Refreshing - Change Url on each request.
Hi,
First, great library - thanks.
I'm using Automatic Refreshing and would like to update the url before the request is made.
Would it be possible to have the url returned as a function? For example....
connect(({ refreshInterval }) => {
return {
dataFetch: {
url: (props) => { return `http://foo.com/${new Date().getTime()}` },
refreshInterval: refreshInterval
}
}
})
...or should I be attempting this some other way.
Many thanks.
Interesting proposal. I guess this would just work if we always allowed url to be a function. I'm not sure I'd want to pass in the props because they'd be the old values, but at least in your case, a no-arg function would work too. Or do you need the props too?
Thanks Ryan.
My full use case is for a url which reads http://foo.com/{id}/{epoch} - The id would be the same across requests, but guess I would need that from the props. epoch would obviously change.
I thought this might do it...
connect((props) => {
return {
dataFetch: {
url: (props) => { return `http://foo.com/${props.id}/${new Date().getTime()}` },
refreshInterval: props.refreshInterval
}
}
})
I didn't realise it would always result in the props having old values though. I'm not familiar with the code base - would that be a difficult thing to make happen?