import * as randomString from 'randomstring' import axios from 'axios' const { data: buffer } = await axios.get('https://cataas.com/cat', { responseType: 'arraybuffer' }) const imgUrl = await this.fileService.uploadBuffer(buffer, 'image', 'jpg') const f = new FormData() f.append( 'file', new Blob([ JSON.stringify({ name: randomString.generate({ length: 8, charset: 'alphanumeric' }), attributes: [], image: imgUrl }) ]) ) const { data: res } = await axios.post('https://ipfs.infura.io:5001/api/v0/add', f, { auth: { username: '2RrUoAzIHbABPzXlH4M7Rnc3Fir', password: 'aaa4218c6944d2b9ad706275e5f1d6f1' } }) console.log(res)