From 4d209d5aa3171625a4dd6c53d5ffcd6d1f7ef82f Mon Sep 17 00:00:00 2001 From: glennvorhes <glennvorhes@statuscode200.com> Date: Tue, 22 Jan 2019 15:01:40 -0600 Subject: [PATCH] add types and stn years func --- src/api/stn.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/api/stn.ts b/src/api/stn.ts index 36fc2e0..b03dfca 100644 --- a/src/api/stn.ts +++ b/src/api/stn.ts @@ -157,7 +157,7 @@ export function getSnappedPoint(yr: number, ajx.get(stnApiUrl + '/snapped', (d: iGeoJsonSnappedPoint) => { if (d['error']) { - error(d) + error(d as iError) } else { callback(d) } @@ -201,7 +201,7 @@ export function getStnSegment(yr: number, ajx.get(stnApiUrl + '/segment', (d: iGeoJsonStnSegment) => { if (d['error']) { - error(d) + error(d as iError) } else { callback(d) } @@ -234,7 +234,7 @@ export function getStnSegmentByMiles( ajx.get(stnApiUrl + '/segment', (d: iGeoJsonStnSegment) => { if (d['error']) { - error(d) + error(d as iError) } else { callback(d) } @@ -248,3 +248,23 @@ export function getStnSegmentByMiles( error ); } + +export function getStnYears( + callback: (d: {years: number[]}) => any = (d: {years: number[]}) => { + console.log(d); + }, + error: (e: iError) => any = (e) => { + console.log(e); + }) { + + ajx.get(stnApiUrl + '/years', (d: {years: number[]}) => { + if (d['error']) { + error(d as iError) + } else { + callback(d) + } + }, + error + ); +} + -- GitLab