I enabled CORS module and set required options in my nodeJS server code. I am able to send the GET request from my browser to the given URL and getting response. But when I am trying to execute below code for sending a GET request using following AngularJS code from WebStorm IDE's built-in server I am getting below error.
city name Delhi
error SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
Code is as follows.
mainApp.controller('dController', function($scope,$http) {
this.ccaid = {
city:'',
circle:'',
area:'',
};
this.getCircle=function(){
console.log('city name ' + this.ccaid.city);
$http({
method: 'GET',
crossDomain:true,
url: 'xx.xxx.xx.xx:3000/fetchCityArea',
params:{city:this.ccaid.city}
}).then(function(success){
console.log('response ' + success);
},function(error){
console.log('error ' + error);
});
};
});
There is nothing wrong with the URL but still it is unable to send GET request.
How can it be resolved?
Does your URL include a scheme? Your example code doesn’t:
url: 'xx.xxx.xx.xx:3000/fetchCityArea',
That needs to have a scheme part—http://
or https://
:
url: 'https://xx.xxx.xx.xx:3000/fetchCityArea',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With