Reputation: 21
I'm trying to do a GET request to api.weatherstack.com (see documentation).
Here's my react effect hook:
useEffect(() => {
if (country === undefined) return
console.log(country.name)
axios
.get('http://api.weatherstack.com/current', {
params: {
access_key: api_key,
query: country.name
}
})
.then(response => {
console.log(response.data)
setWeather(response.data)
})
}, [api_key, country])
However, every single time I run this, I get this error:
{ code: 105, type: "https_access_restricted", info: "Access Restricted - Your current Subscription Plan does not support HTTPS Encryption." }
Doing the API call through my browser or through Postman works perfectly, so I'm thinking that there's probably an issue with how I'm using React or Axios.
Also, this API call works about 10% of the time, so I'm confused about why that might happen too.
Upvotes: 2
Views: 2877
Reputation: 1
Try using postman or ajax call, it works. All their http: urls are redirected to https:
Upvotes: 0
Reputation: 1
Try: API Request
url: http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEYf&query=New%20York
From Documentation: https://weatherstack.com/documentation
Upvotes: 0
Reputation: 19
Try:
.get("http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=country.name)
on line 5.
Remove the params: {}
on lines 6-9
Upvotes: 0
Reputation: 490
I think it's because you are using the free plan
weatherstack.com https encryption
Upvotes: 0