Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
request(options) {
const observable = this._requestObservable(options).pipe(
filter(event => event.type === 'response'),
map(event => event.body)
)
return this.isPromiseAPI() ? toPromise(observable) : observable
}
})
getDocuments(ids) {
const options = {uri: this.getDataUrl('doc', ids.join(',')), json: true}
const observable = this._requestObservable(options).pipe(
filter(isResponse),
map(event => {
const indexed = indexBy(event.body.documents || [], doc => doc._id)
return ids.map(id => indexed[id] || null)
})
)
return this.isPromiseAPI() ? toPromise(observable) : observable
},
query.sourceName = source.name
query.sourceUrl = source.url
}
const observable = this.client._requestObservable({
method: 'POST',
timeout: options.timeout || 0,
uri: `/assets/${assetEndpoint}/${dataset}`,
headers: options.contentType ? {'Content-Type': options.contentType} : {},
query,
body
})
return this.client.isPromiseAPI()
? observable
.pipe(
filter(event => event.type === 'response'),
map(event => toDocument(event.body))
)
.toPromise()
: observable
},