Closed bmazerolle closed 3 years ago
Hi Ben,
I'm seeing the same error, I don't think it's a mistake on your end.
The issue seems to be that the app thinks it's receiving a request to the home page. This is the output on the Heroku console:
2021-02-20T19:18:49.491101+00:00 heroku[router]: at=info method=GET path="/" host=www.ferrytimes.ca request_id=747090c3-10bf-4670-a10b-c7f93505504d fwd="96.54.46.229" dyno=web.1 connect=1ms service=4ms status=200 bytes=3963 protocol=http
2021-02-20T19:18:49.490237+00:00 app[web.1]: 10.47.227.158 - - [20/Feb/2021:19:18:49 +0000] "GET / HTTP/1.1" 200 3769 "https://ferrytimes.ca/api/" "PostmanRuntime/7.26.8"
So it recognizes that the full request url includes '/api/' but the flask app returns the base url instead,
I'll start on this today, but I'm not sure what the issue could be. It works when running locally though, so if this is a blocker for your project you could run the api locally until this is fixed.
Not sure the cause for it, but when sending requests in postman add www.
to the start of the url, it should work then.
It looks like this isn't an issue with the code but with the domain name setup, so I'll close this issue and fix it over there.
Thanks for finding this and opening an issue! If you're interested in contributing further there's other open issues, or if you see other improvements not listed feel free to open a PR.
Hi Sam,
This is an awesome project, thanks a bunch for doing this.
I am pretty new to working with APIs so I am hoping I'm just making a stupid mistake in my request. I'm working in React with a basic fetch() call:
fetch("https://ferrytimes.ca/api/tsawwassen", { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }}) .then(function(response) { return response.text(); }).then(function(data) { console.log(data); }) .catch(error => console.log('Authorization failed : ' + error.message));
This returns the source html of your home page itself rather than the json data I was looking for. I tried using
response.json()
but get a "Unexpected token < in JSON at position 0" error which indicates to me I'm not receiving the json response. I also tried using postman to the same effect so I assume I am just looking at the wrong api link.Any help is appreciated, thanks again and I look forward to being able to contribute to your project in the near future.