Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Created June 3, 2019 02:10
Show Gist options
  • Select an option

  • Save alexytiger/372dccdee5f05f4aac17c7e44b3b40f0 to your computer and use it in GitHub Desktop.

Select an option

Save alexytiger/372dccdee5f05f4aac17c7e44b3b40f0 to your computer and use it in GitHub Desktop.
import { Injectable, InjectionToken, Inject } from '@angular/core';
import { providers } from 'ethers';
import IpfsHttpClient from 'ipfs-http-client';
export const ipfsToken = new InjectionToken('The IPFS Token', {
providedIn: 'root',
factory: () => {
try {
return new IpfsHttpClient('ipfs.infura.io', '5001', {
protocol: 'https'
});
} catch (err) {
console.log('Error', err);
throw new Error('Unable to access IPFS node daemon on Infura network');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment