Start a new topic

x-forwarded-for saw as a for loop

I am trying to get the ip address by getting request.header.x-forwarded-for. However the editor gave me an error as seeing the "for" as a for loop. is there any easy way I can get the ip address in BL. Thank you. 

1 Comment

Hi Kevin,

In JavaScript, objects are associative arrays. When working with property names that are not valid JS identifiers (such as ones that include a dash), you can use the array-like syntax, which in your case would be:

 

request.header["x-forwarded-for"]

 

For more information about working with objects, you can go here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects


Hope this helps.

 

Login or Signup to post a comment