From 1515b555a17ec5da9317327171cf24f74d2a8c25 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sun, 10 May 2020 21:20:26 +0200 Subject: [PATCH] fix: suggest ipfs-provider for window.ipfs fallback The other library was superseded by ipfs-provider License: MIT Signed-off-by: Marcin Rataj --- docs/how-to/companion-window-ipfs.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/how-to/companion-window-ipfs.md b/docs/how-to/companion-window-ipfs.md index 5b0d5cb61..fb4b36bb3 100644 --- a/docs/how-to/companion-window-ipfs.md +++ b/docs/how-to/companion-window-ipfs.md @@ -13,13 +13,13 @@ Learn about exposing IPFS API in IPFS Companion via "window.ipfs". IPFS Companion 2.11 stopped injecting `window.ipfs`. It will be restored after the [move to JS API with async await and async iterables](https://github.com/ipfs-shipyard/ipfs-companion/issues/843), with a likely ETA of Q3 2020. This page is provided for reference only. -::: - + -The interface is experimental and might change. Use [window.ipfs-fallback](https://www.npmjs.com/package/window.ipfs-fallback) to ensure your app follows any future changes +::: ## Background @@ -45,6 +45,10 @@ if (window.ipfs && window.ipfs.enable) { To add and get content, you could update the above example to do something like this: + + ```js if (window.ipfs && window.ipfs.enable) { try { @@ -67,6 +71,12 @@ if (window.ipfs && window.ipfs.enable) { } ``` +::: tip + +Use [ipfs-provider](https://github.com/ipfs-shipyard/ipfs-provider) to ensure your app follows any future changes of this interface. It reduces amount of code needed to implement a robust fallback to HTTP API or embedded js-ipfs when `window.ipfs` is not available. + +::: + ### Error codes Errors returned by IPFS proxy can be identified by the value of the `code` attribute.