сначала я думаю, что проблема скорее состоит в том, чтобы понять, что API возвращает вам
Команда: curl http://127.0.0.1:5001/api/v0/ls?arg=QmSYQqCHX9LBbvfY86oBQGjCPpok4EAjPxUy7wrCWn8tuV | sed -e "s/{/\n{/g"
возвращает:
{"Objects":[
{"Hash":"QmSYQqCHX9LBbvfY86oBQGjCPpok4EAjPxUy7wrCWn8tuV","Links":[
{"Name":"chose.dat","Hash":"QmUtAten38KKm8b7omXhmiJP1QT49mMWLeHJQK3yPnAmBr","Size":9,"Type":2,"Target":""},
{"Name":"chose.txt","Hash":"QmUtAten38KKm8b7omXhmiJP1QT49mMWLeHJQK3yPnAmBr","Size":9,"Type":2,"Target":""},
{"Name":"machi.dat","Hash":"QmPG68xD8CcrjcN5Efo3TM5PY77AMQiyZfAgR1snqauG3g","Size":499,"Type":2,"Target":""},
{"Name":"machin.chose","Hash":"QmUVmCWPJjaoxZ8d4XRVckyPaphzA1aKauNepZ5uR5rKkT","Size":111,"Type":2,"Target":""},
{"Name":"machine","Hash":"QmNTFx9vRLvMS6tC5m1MLqtt42j5LJKm4KQ8igdxWbRoqr","Size":1156,"Type":2,"Target":""},
{"Name":"s.txt","Hash":"QmeKMRaYxbP6r8wqeswtroXdQCAw72t9HxS4gAK6UvrnGF","Size":15,"Type":2,"Target":""},
{"Name":"sentence.txt","Hash":"QmPHrjJSuMw6TRFq9vWD6WkbzN6MwDFQeKLh9owTPstaDq","Size":17,"Type":2,"Target":""},
{"Name":"set.dat","Hash":"QmbkS4z9LH2LkBrooEQDMhZdUzBzqZ7waAVAAAhQRWXVwv","Size":2847,"Type":2,"Target":""},
{"Name":"si.txt","Hash":"QmRGebxmjHxxhAXjBgczU5QEWsNmBaKapV1TGsa4AY1mMt","Size":15,"Type":2,"Target":""},
{"Name":"simple.txt","Hash":"QmRGebxmjHxxhAXjBgczU5QEWsNmBaKapV1TGsa4AY1mMt","Size":15,"Type":2,"Target":""},
{"Name":"spot.dat","Hash":"QmZTerejEeCfijBv4y8CZqu6P8s2BUwyi7VpDBCPFE9sDd","Size":111,"Type":2,"Target":""},
{"Name":"spot.yml","Hash":"QmU1JhyC7Qegt29sg1o2u2pdb1XY43MZp6srJMciQLgNQk","Size":111,"Type":2,"Target":""},
{"Name":"string","Hash":"QmcUwH9vFa6mV1KaGuFjQEttdiKGRsUUE9CP5Aha8F37R6","Size":9,"Type":2,"Target":""},
{"Name":"temp","Hash":"QmUtAten38KKm8b7omXhmiJP1QT49mMWLeHJQK3yPnAmBr","Size":9,"Type":2,"Target":""},
{"Name":"toto","Hash":"QmRGebxmjHxxhAXjBgczU5QEWsNmBaKapV1TGsa4AY1mMt","Size":15,"Type":2,"Target":""},
{"Name":"truc","Hash":"QmZTerejEeCfijBv4y8CZqu6P8s2BUwyi7VpDBCPFE9sDd","Size":111,"Type":2,"Target":""},
{"Name":"truc.dat","Hash":"QmSkG1t12biXNHWzckFwDAXsdjtvybVH3UBfDJQquCnJ9y","Size":2847,"Type":2,"Target":""},
{"Name":"trucZ","Hash":"QmXYsmrQPmJc56Pk7SBQREYWp5kB8QLjtQWr8mEXRhNUaE","Size":111,"Type":2,"Target":""}]}]}
, поэтому с микс карт и списков, вы должны быть осторожны, чтобы правильно проанализировать json, вот фрагмент кода html, который может сделать то, что вы хотите:
<!DOCTYPE html>
<div id=result></div>
<script>
let ipfs_path = '/ipfs/QmSYQqCHX9LBbvfY86oBQGjCPpok4EAjPxUy7wrCWn8tuV';
let url = 'http://127.0.0.1:5001/api/v0/ls?arg='+ipfs_path;
console.log('url:'+url);
fetch(url, { method: "POST", mode: 'cors'})
.then (resp => {return resp.json()})
.then (json => json.Objects)
.then (readObj)
function readObj(obj) {
console.dir(obj);
let buf = ''
for (let i=0; i<obj[0].Links.length; i++) {
let file=obj[0].Links[i];
console.log('// file '+i+': '+file.Hash)
buf += '// file '+i+':<br>name: '+file.Name+'<br>hash: '+file.Hash+'<br>size: '+file.Size+'<br>.';
}
document.getElementById('result').innerHTML = buf;
}
</script>