[beginner]
js-ipfs is same as ipfs-http-client right ?
()https://www.npmjs.com/package/ipfs-http-client
I have made a private network using my pc and an instance from aws
i want to add files onto this network, check nodes added in the swarm, etc
Here’s what i have done and what i get
const ipfsClient = require (“ipfs-http-client”)
//tried these two :
var ipfs = ipfsClient(’/ip4/35.154.130.223/tcp/4001’)
//and
var ipfs = ipfsClient({ host: ‘35.154.130.223’, port: ‘4001’, ‘api-path’: ‘/ipfs/api/v0’ })
ipfs.swarm.peers((err, peers) => {
console.log("1"err)
console.log("2"peers)
})
ipfs.config.get((err, config) => {
if (err) {
throw err
}
console.log(“consigggggg”,config)
})
Attaching output
terminal above shows the network running, and peers added to the swarm
terminal below shows the output of the code
js-ipfs-http-client
is a smaller library than js-ipfs
js-ipfs
is a full implementation of IPFS
js-ipfs-http-client
is a smaller library that controls an IPFS node that is already running via its HTTP API.
(refer to https://docs.ipfs.io/reference/js/overview/)
You should run an ipfs daemon locally.
(refer to GitHub - ipfs-inactive/js-ipfs-http-client: [ARCHIVED] now part of the https://github.com/ipfs/js-ipfs repo)
var ipfsClient = require('ipfs-http-client')
// connect to ipfs daemon API server
var ipfs = ipfsClient('localhost', '5001', { protocol: 'http' }) // leaving out the arguments will default to these values
// or connect with multiaddr
var ipfs = ipfsClient('/ip4/127.0.0.1/tcp/5001')
// or using options
var ipfs = ipfsClient({ host: 'localhost', port: '5001', protocol: 'http' })
// or specifying a specific API path
var ipfs = ipfsClient({ host: '1.1.1.1', port: '80', 'api-path': '/ipfs/api/v0' })
Can i not use it with my private network