AstronomyAPI / Samples

Examples for Astronomy API
https://astronomyapi.com
MIT License
31 stars 3 forks source link

422 Error when using star chart #109

Closed Stanley9986 closed 6 days ago

Stanley9986 commented 1 week ago

Hey,

I'm working on a website that when given the long/lat and the date, it gives them the image of the star chart. However, I can't seem to retrieve the JSON object so when I did some debugging and found that res.status is 422.

This is a snippet of my JS code right now: const authString = btoa(applicationId:applicationSecret); const res = await fetch("https://api.astronomyapi.com/api/v2/studio/star-chart", { method: "POST", headers: { "Authorization": Basic ${authString}, "Content-Type": "application/json" }, body: JSON.stringify({ "style": "navy", "observer": { "latitude": latitude, "longitude": longitude, "date": date }, "view": { "type": "constellation", "parameters": { "constellation": "ori" } } }) });

Is there anything that's wrong with the format? Thanks in advance!

astroanu commented 6 days ago

The values you're passing, such as latitude, longitude, or date, could be the issue. What does the response say ?

See this page for examples of supported values and their data types. -> https://docs.astronomyapi.com/requests-and-response/observer-parameters

latitude and longitude must be float values see example -> https://github.com/AstronomyAPI/Samples/blob/master/vue/js/components/StarChart.vue#L203