Merge pull request #74 from Derpthemeus/dont-error-on-missing-key

Silently fallback to default WeatherProvider if WUnderground API key is omitted
This commit is contained in:
Samer Albahra
2019-07-12 16:46:22 -07:00
committed by GitHub

View File

@@ -219,11 +219,7 @@ export const getWateringData = async function( req: express.Request, res: expres
// Parse the PWS information. // Parse the PWS information.
let pws: PWS | undefined = undefined; let pws: PWS | undefined = undefined;
if ( adjustmentOptions.pws ) { if ( adjustmentOptions.pws && adjustmentOptions.key ) {
if ( !adjustmentOptions.key ) {
res.send("Error: An API key must be provided when using a PWS.");
return;
}
const idMatch = adjustmentOptions.pws.match( /^pws:([a-zA-Z\d]+)$/ ); const idMatch = adjustmentOptions.pws.match( /^pws:([a-zA-Z\d]+)$/ );
const pwsId = idMatch ? idMatch[ 1 ] : undefined; const pwsId = idMatch ? idMatch[ 1 ] : undefined;