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