Maybe try creating a bucket and then reading the region?
Maybe try creating a bucket and then reading the region?




wrangler tail right?.json()properties.periods doesn't exist, for example..ok and also check if the content-type includes application/json. You'd be surprised at how many APIs are wonky sometimes and return a 200 but an HTML error page or something.properties doesn't exist there, you'll get a TypeError. I'd check proto_res.properties exists tooif(!proto_res?.properties?.periods) with optional chaining.properties.periods would throw a TypeError if properties doesn't exist. For example:.json()properties.periods.okcontent-type.propertiesTypeErrorTypeErrorproto_res.propertiesif(!proto_res?.properties?.periods).properties.periodsproperties//get hourly weather
const wthr: Result<Period> = await (async () => {
const proto_res = (await (await fetch(`${WeatherAPIEndpoint}/hourly`, { body: null, method: 'GET', headers: fetch_headers})).json()) as WeatherData|undefined;
if (!exists(proto_res) || !exists(proto_res.properties.periods)) return new Err(`No data from ${WeatherAPIEndpoint}/hourly`);
const result = proto_res.properties.periods.filter(p => (dateIsoToUnixSec(p.startTime)*1000 > now))[0];
if (exists(result)) return new Ok(result);
return new Err("Data too old");
})();
if (!wthr.isOk()) return;
//get overall day dorcast
const day_forcase = await (async () => {
const proto_res = (await (await fetch(WeatherAPIEndpoint, { body: null, method: 'GET', headers: fetch_headers})).json()) as WeatherData|undefined;
if (!exists(proto_res) || !exists(proto_res.properties.periods)) return new Err(`No data from ${WeatherAPIEndpoint}`);
const result = proto_res.properties.periods.find(p => (p.number == 1));
if (exists(result)) return new Ok(result);
return new Err("Today's data not found");
})();[placement]
mode = "smart"if (!exists(proto_res) || !exists(proto_res.properties.periods)) return new Err(`No data from ${WeatherAPIEndpoint}/hourly`);const fetch_headers = {
'User-Agent': `${fitweather_credentials.name}/1.0 (Florida Institute of Technology Weather Discord Bot (Student Run), https://github.com/DaBigBlob/FIT-Weather-Chan)`,
'Accept': "application/geo+json"
};export function exists<T>(data: T|null|undefined): data is T {
if (
(data === null) ||
(data === undefined)
) return false;
return true;
}const obj = {foo: 'bar'}
console.log(obj.foo) // bar
console.log(obj.bar) // undefined
console.log(obj.bar.baz) // TypeError