I wanted to try the elegance of the API you created, and I am happy what it provides , the thing is … .it works with curl but trying to use it with fetch I saw that I am dealing with streams I hope someone can help me understand why streams?
how to retrieve first meaningful result here is the code:
fetch(
`https://deep-index.moralis.io/api/v2/${process.env.contractAddress}/function?chain=${process.env.chain}&function_name=${function_name}`,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-API-Key': process.env.MORALIS_API_KEY
},
body: JSON.stringify({
abi: abi,
params
})
}
)
.then(response => response.body)
.then(body => {
const reader = body.getReader()
reader.read().then(({ value, done }) => {
const result = Utf8ArrayToStr(value)
console.log(result)
if (result) {
resolve(result)
}
})
})