非常感谢,非常好的解决方案
我把它作为我的问题的基础,但我没有解决它,因为它给了我互联网服务器的公共IP.
对于具有DHCP的内部网络,请通过以下方式更改URL:
getIpCliente(): Observable {
return this.http.get('/?format=jsonp&callback=JSONP_CALLBACK') // ...using post request '
.map((res:Response) => {console.log('res ', res);
console.log('res.json() ', res.text());
//console.log('parseado ', JSON.parse(res.text()));
console.log('parseado stringify ', JSON.stringify(res.text()));
let ipVar = res.text();
let num = ipVar.indexOf(":");
let num2 = ipVar.indexOf("\"});");
ipVar = ipVar.slice(num+2,num2);
console.log('ipVar -- ',ipVar);
return ipVar}); // ...and calling .json() on the response to return data
//.catch((error:any) => Observable.throw(error.json().error || 'Server error')); //...errors if any
}
我希望能为你的朋友服务
拥抱!