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

extra check

This commit is contained in:
alexcos20 2020-09-16 06:31:40 -07:00
parent 17e61d0108
commit 48cb847082

View File

@ -284,13 +284,17 @@ export class Provider extends Instantiable {
return `${this.url}${apiPath}/download` return `${this.url}${apiPath}/download`
} }
/** Check for a valid provider at URL
* @param {String} url
* @return {Promise<boolean>} string
*/
public async isValidProvider(url: string): Promise<boolean> { public async isValidProvider(url: string): Promise<boolean> {
const fetch = this.ocean.utils.fetch.get(url) const fetch = this.ocean.utils.fetch.get(url)
await fetch await fetch
.then((response: Response) => { .then((response: Response) => {
if (response.ok) { if (response.ok) {
const params = response.json() const params = response.json()
if (params) return true if (params['provider-address']) return true
} }
return false return false
}) })