libp2p
    Preparing search index...

    Interface Fetch

    interface Fetch {
        protocol: string;
        fetch(
            peer: DialTarget,
            key: string | Uint8Array<ArrayBufferLike>,
            options?: DialProtocolOptions,
        ): Promise<Uint8Array<ArrayBufferLike> | undefined>;
        registerLookupFunction(prefix: string, lookup: LookupFunction): void;
        unregisterLookupFunction(prefix: string, lookup?: LookupFunction): void;
    }
    Index

    Properties

    protocol: string

    The protocol this Fetch instance supports

    libp2p.register(libp2p.services.fetch.protocol, {
    onConnect (peerId) {
    // handle fetch peer connect
    }
    // ...etc
    })

    Methods

    • Registers a new lookup callback that can map keys to values, for a given set of keys that share the same prefix

      Parameters

      Returns void

      // ...
      libp2p.services.fetch.registerLookupFunction('/prefix', (key) => { ... })
    • Registers a new lookup callback that can map keys to values, for a given set of keys that share the same prefix.

      Parameters

      Returns void

      // ...
      libp2p.services.fetch.unregisterLookupFunction('/prefix')