Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  0] [ 1]  / answers: 1 / hits: 31729  / 8 Years ago, tue, june 14, 2016, 12:00:00

I can parse are HTTP response of one of the intial calls and save that in the state but there must be another way to get the URL?



I am using the npm 'rest' library and want to specify a different port but I do not know the path on which machine the server will be installed so I need the server's url.



Solution



window.location.hostname


More From » reactjs

 Answers
11

location is a property on the window object with a bunch of information, you can get the url with window.location.href



You can get the hostname with window.location.hostname


[#61769] Sunday, June 12, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josuea

Total Points: 609
Total Questions: 121
Total Answers: 104

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
josuea questions
;