@@ -149,7 +149,7 @@ export class VsoClient {
149
149
* @param area resource area name
150
150
* @param locationId Guid of the location to get
151
151
*/
152
- public beginGetLocation ( area : string , locationId : string ) : Promise < ifm . ApiResourceLocation > {
152
+ public beginGetLocation ( area : string , locationId : string ) : Promise < ifm . ApiResourceLocation | undefined > {
153
153
return this . _initializationPromise . then ( ( ) => {
154
154
return this . beginGetAreaLocations ( area ) ;
155
155
} ) . then ( ( areaLocations : VssApiResourceLocationLookup ) => {
@@ -162,7 +162,11 @@ export class VsoClient {
162
162
if ( ! areaLocationsPromise ) {
163
163
let requestUrl = this . resolveUrl ( VsoClient . APIS_RELATIVE_PATH + "/" + area ) ;
164
164
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
+
166
170
let locationsLookup : VssApiResourceLocationLookup = { } ;
167
171
let resourceLocations : ifm . ApiResourceLocation [ ] = res . result . value ;
168
172
let i ;
@@ -190,7 +194,7 @@ export class VsoClient {
190
194
}
191
195
let queryString : string = '' ;
192
196
193
- if ( typeof ( queryParams ) !== 'string' ) {
197
+ if ( typeof ( queryParams ) !== 'string' ) {
194
198
for ( let property in queryParams ) {
195
199
if ( queryParams . hasOwnProperty ( property ) ) {
196
200
const prop = queryParams [ property ] ;
@@ -200,14 +204,14 @@ export class VsoClient {
200
204
}
201
205
}
202
206
203
- if ( queryString === '' && prefix . length > 0 ) {
207
+ if ( queryString === '' && prefix . length > 0 ) {
204
208
// Date.prototype.toString() returns a string that is not valid for the REST API.
205
209
// Need to specially call `toUTCString()` instead for such cases
206
210
const queryValue = typeof queryParams === 'object' && 'toUTCString' in queryParams ? ( queryParams as Date ) . toUTCString ( ) : queryParams . toString ( ) ;
207
211
208
212
209
213
// 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 ) + '&' ;
211
215
}
212
216
return queryString ;
213
217
}
@@ -216,7 +220,7 @@ export class VsoClient {
216
220
const queryString : string = '?' + this . queryParamsToStringHelper ( queryParams , '' ) ;
217
221
218
222
// Will always need to slice either a ? or & off of the end
219
- return queryString . slice ( 0 , - 1 ) ;
223
+ return queryString . slice ( 0 , - 1 ) ;
220
224
}
221
225
222
226
protected getRequestUrl ( routeTemplate : string , area : string , resource : string , routeValues : any , queryParams ?: any ) : string {
0 commit comments