@@ -149,7 +149,7 @@ export class VsoClient {
149149 * @param area resource area name
150150 * @param locationId Guid of the location to get
151151 */
152- public beginGetLocation ( area : string , locationId : string ) : Promise < ifm . ApiResourceLocation > {
152+ public beginGetLocation ( area : string , locationId : string ) : Promise < ifm . ApiResourceLocation | undefined > {
153153 return this . _initializationPromise . then ( ( ) => {
154154 return this . beginGetAreaLocations ( area ) ;
155155 } ) . then ( ( areaLocations : VssApiResourceLocationLookup ) => {
@@ -162,7 +162,11 @@ export class VsoClient {
162162 if ( ! areaLocationsPromise ) {
163163 let requestUrl = this . resolveUrl ( VsoClient . APIS_RELATIVE_PATH + "/" + area ) ;
164164 areaLocationsPromise = this . restClient . options < any > ( requestUrl )
165- . then ( ( res :restm . IRestResponse < any > ) => {
165+ . then ( ( res : restm . IRestResponse < any > ) => {
166+ if ( ! res . result ) {
167+ return { } ;
168+ }
169+
166170 let locationsLookup : VssApiResourceLocationLookup = { } ;
167171 let resourceLocations : ifm . ApiResourceLocation [ ] = res . result . value ;
168172 let i ;
@@ -190,7 +194,7 @@ export class VsoClient {
190194 }
191195 let queryString : string = '' ;
192196
193- if ( typeof ( queryParams ) !== 'string' ) {
197+ if ( typeof ( queryParams ) !== 'string' ) {
194198 for ( let property in queryParams ) {
195199 if ( queryParams . hasOwnProperty ( property ) ) {
196200 const prop = queryParams [ property ] ;
@@ -200,14 +204,14 @@ export class VsoClient {
200204 }
201205 }
202206
203- if ( queryString === '' && prefix . length > 0 ) {
207+ if ( queryString === '' && prefix . length > 0 ) {
204208 // Date.prototype.toString() returns a string that is not valid for the REST API.
205209 // Need to specially call `toUTCString()` instead for such cases
206210 const queryValue = typeof queryParams === 'object' && 'toUTCString' in queryParams ? ( queryParams as Date ) . toUTCString ( ) : queryParams . toString ( ) ;
207211
208212
209213 // Will always need to chop period off of end of prefix
210- queryString = prefix . slice ( 0 , - 1 ) + '=' + encodeURIComponent ( queryValue ) + '&' ;
214+ queryString = prefix . slice ( 0 , - 1 ) + '=' + encodeURIComponent ( queryValue ) + '&' ;
211215 }
212216 return queryString ;
213217 }
@@ -216,7 +220,7 @@ export class VsoClient {
216220 const queryString : string = '?' + this . queryParamsToStringHelper ( queryParams , '' ) ;
217221
218222 // Will always need to slice either a ? or & off of the end
219- return queryString . slice ( 0 , - 1 ) ;
223+ return queryString . slice ( 0 , - 1 ) ;
220224 }
221225
222226 protected getRequestUrl ( routeTemplate : string , area : string , resource : string , routeValues : any , queryParams ?: any ) : string {
0 commit comments