1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
This commit is contained in:
mihaisc 2021-12-20 04:24:34 -08:00 committed by GitHub
parent 602f453985
commit ec61424546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@ export class Provider {
async getEndpoints(providerUri: string): Promise<any> { async getEndpoints(providerUri: string): Promise<any> {
try { try {
const endpoints = await getData(providerUri) const endpoints = await getData(providerUri)
return endpoints return await endpoints.json()
} catch (e) { } catch (e) {
LoggerInstance.error('Finding the service endpoints failed:', e) LoggerInstance.error('Finding the service endpoints failed:', e)
return null return null
@ -127,7 +127,7 @@ export class Provider {
document: any, document: any,
providerUri: string, providerUri: string,
fetchMethod: any fetchMethod: any
): Promise<string> { ): Promise<any> {
const providerEndpoints = await this.getEndpoints(providerUri) const providerEndpoints = await this.getEndpoints(providerUri)
const serviceEndpoints = await this.getServiceEndpoints( const serviceEndpoints = await this.getServiceEndpoints(
providerUri, providerUri,
@ -142,10 +142,11 @@ export class Provider {
const path = this.getEndpointURL(serviceEndpoints, 'encrypt') const path = this.getEndpointURL(serviceEndpoints, 'encrypt')
? this.getEndpointURL(serviceEndpoints, 'encrypt').urlPath ? this.getEndpointURL(serviceEndpoints, 'encrypt').urlPath
: null : null
if (!path) return null if (!path) return null
try { try {
const response = await fetchMethod(path, decodeURI(JSON.stringify(args))) const response = await fetchMethod(path, decodeURI(JSON.stringify(args)))
return (await response.json()).encryptedDocument return response
} catch (e) { } catch (e) {
LoggerInstance.error(e) LoggerInstance.error(e)
throw new Error('HTTP request failed') throw new Error('HTTP request failed')