remoteDatastore.jsView |
---|
1 | 1 | const Buffer = require('safe-buffer').Buffer |
2 | 2 | const TreeDAG = require('./datastore.js') |
3 | | -const fetch = typeof window !== 'undefined' ? window.fetch : require('node-fetch') |
| 3 | +const fetch = require('node-fetch') |
4 | 4 | |
5 | 5 | module.exports = class RemoteTreeDAG extends TreeDAG { |
6 | 6 | |
7 | 7 | * @param dag {object} a level db instance |
20 | 20 | |
21 | 21 | async get (link) { |
22 | 22 | try { |
23 | 23 | return await super.get(link) |
24 | | - } catch (e) {} |
25 | | - |
26 | | - if (this.remoteOpts.uri) { |
27 | | - await this.fetchRemote(link) |
28 | | - return super.get(link) |
| 24 | + } catch (e) { |
| 25 | + if (this.remoteOpts.uri) { |
| 26 | + await this.fetchRemote(link) |
| 27 | + return super.get(link) |
| 28 | + } |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | 32 | fetchRemote (key) { |