tzkt / api-sdk-ts

Typed SDK for TzKT API
https://sdk.tzkt.io
MIT License
17 stars 0 forks source link

ReferenceError: fetch is not defined #21

Closed wshbair closed 1 year ago

wshbair commented 1 year ago

I am using the library to interact with Tezos blockchain via Nodejs application. The source code

import * as api from '@tzkt/sdk-api';
api.defaults.baseUrl = 'https://api.ghostnet.tzkt.io/'

async function getTransaction()
{
  const receipt = await api.operationsGetByHash("oopzR8DwzX9VLrSoeJP4WirFWz22SkA2AZ7TM4K1yHSGKzViDme");
  console.log(receipt);
}
getTransaction();

The error msg is :

/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:78
        const res = await (customFetch || fetch)(href, {
                                          ^
ReferenceError: fetch is not defined
    at doFetch (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:78:43)
    at fetchText (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:32:27)
    at Object.fetchJson (/../nodejsexample/node_modules/@tzkt/oazapfts/lib/runtime/index.js:46:62)
    at Module.operationsGetByHash (/../nodejsexample/node_modules/@tzkt/sdk-api/build/main/index.js:684:33)
    at getTransaction (file:///../nodejsexample/index.js:119:29)
    at file:///../nodejsexample/index.js:123:1
wshbair commented 1 year ago

I was using node v16 after after updating to v20 its works