1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

more checks on provider

This commit is contained in:
alexcos20 2021-02-23 23:50:01 -08:00
parent 57c1457b83
commit 2cbc02e1d5

View File

@ -283,10 +283,10 @@ export class Provider extends Instantiable {
if (additionalInputs) payload.additionalInputs = additionalInputs if (additionalInputs) payload.additionalInputs = additionalInputs
try { try {
const response = await this.ocean.utils.fetch.post( let path = null
this.getComputeStartEndpoint().urlPath, if (this.getComputeStartEndpoint().urlPath)
JSON.stringify(payload) path = this.getComputeStartEndpoint().urlPath
) const response = await this.ocean.utils.fetch.post(path, JSON.stringify(payload))
if (response?.ok) { if (response?.ok) {
const params = await response.json() const params = await response.json()
return params return params
@ -322,10 +322,10 @@ export class Provider extends Instantiable {
payload.jobId = jobId payload.jobId = jobId
payload.consumerAddress = address payload.consumerAddress = address
try { try {
const response = await this.ocean.utils.fetch.put( let path = null
this.getComputeStopEndpoint().urlPath, if (this.getComputeStopEndpoint().urlPath)
JSON.stringify(payload) path = this.getComputeStopEndpoint().urlPath
) const response = await this.ocean.utils.fetch.put(path, JSON.stringify(payload))
if (response?.ok) { if (response?.ok) {
const params = await response.json() const params = await response.json()
return params return params
@ -361,10 +361,10 @@ export class Provider extends Instantiable {
payload.jobId = jobId payload.jobId = jobId
payload.consumerAddress = address payload.consumerAddress = address
try { try {
const response = await this.ocean.utils.fetch.delete( let path = null
this.getComputeDeleteEndpoint().urlPath, if (this.getComputeDeleteEndpoint().urlPath)
JSON.stringify(payload) path = this.getComputeDeleteEndpoint().urlPath
) const response = await this.ocean.utils.fetch.delete(path, JSON.stringify(payload))
if (response?.ok) { if (response?.ok) {
const params = await response.json() const params = await response.json()
return params return params
@ -408,11 +408,11 @@ export class Provider extends Instantiable {
url += `&consumerAddress=${address}` url += `&consumerAddress=${address}`
url += (txId && `&transferTxId=${txId}`) || '' url += (txId && `&transferTxId=${txId}`) || ''
let response
try { try {
const response = await this.ocean.utils.fetch.get( let path = null
this.getComputeStatusEndpoint().urlPath + url if (this.getComputeStatusEndpoint().urlPath)
) path = this.getComputeStatusEndpoint().urlPath
const response = await this.ocean.utils.fetch.get(path + url)
/* response = await fetch(this.getComputeEndpoint() + url, { /* response = await fetch(this.getComputeEndpoint() + url, {
method: 'GET', method: 'GET',
timeout: 5000 timeout: 5000