-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sunrise and sunset examples incorrect? #3
Comments
Hi, thanks for the report. Yes, the demo code generator on the API documentation does not select the right array for sunrise and sunset. The ideal code would be |
Thanks! Oh I see, yeah I'm only fetching for one day but I can see how it'd be useful to fetch an array if you're fetching forecasts for multiple days. It doesn't seem like
|
looks like the demo code generator is still broken, can't figure out how to get sunrise/sunset out... tried this: sunrise: daily.variables(2)!.valuesInt64(0)!,
sunset: daily.variables(3)!.valuesInt64(0)!, but no joy, I also can't access |
ended up using this for them: function sunToArray(index: number) {
const array: bigint[] = [];
const count = daily.variables(index)?.valuesInt64Length() as number;
for (let i = 0; i < count; i++) {
array.push(daily.variables(index)?.valuesInt64(i) as bigint);
}
return array;
} and then in sunrise: sunToArray(2),
sunset: sunToArray(3), |
Maybe I'm doing something wrong, but I've been having trouble using sunrise and sunset with the TypeScript SDK. I figured a way to make it work; not sure if this is the right way of doing it. If so, I think it'd be useful to update the example code.
Steps to Reproduce the Problem
Use the example TypeScript code from the docs/demo site
sunrise: daily.variables(0)!.valuesArray()!
Fix
Instead, I got this code to work with a hint from the SDK schema docs
sunrise: Number(daily.variables(0)!.valuesInt64(0))
Environment
The text was updated successfully, but these errors were encountered: