Select to view content in your preferred language

request interceptor bind additional parameter

1607
6
Jump to solution
03-25-2021 09:15 AM
RobertScheitlin__GISP
MVP Emeritus

How do you pass additional parameters to the request interceptor before or after functions?

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor
One option is that the default value of "this" inside the "before" function is the interceptor object itself. It looks like "const" also has scope inside the "before" function. Does that sound useful? Example: https://codepen.io/noash/pen/ZELpXBG?editors=1000
 

If not, it would be easier to have a simplified repro case to diagnose. I'd like to see how you are currently using bind.

View solution in original post

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
Noah-Sager
Esri Regular Contributor

@RobertScheitlin__GISP - I'm not sure I understand. Are you asking for how to send two or more parameters to the before/after functions?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Noah,

   The issue I am having is that the scope of the inteceptor before or after functions have no access to vars or any scope outside the function. So I have tried .bind(this) and every other trick I am aware of. So I am wondering if you can pass an additional parameter or bind to the outside scope of the function.

Robert

0 Kudos
Noah-Sager
Esri Regular Contributor

Ok, I think I understand better now. I don't know an answer off the top of my hand, but I will look into it.

Noah-Sager
Esri Regular Contributor
One option is that the default value of "this" inside the "before" function is the interceptor object itself. It looks like "const" also has scope inside the "before" function. Does that sound useful? Example: https://codepen.io/noash/pen/ZELpXBG?editors=1000
 

If not, it would be easier to have a simplified repro case to diagnose. I'd like to see how you are currently using bind.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Noah,

   That works prefect for me. Thanks.

0 Kudos