adobe / aem-headless-client-nodejs

AEM Headless Client for Node.js
Apache License 2.0
9 stars 1 forks source link

originalFetch is not a function #16

Open thanneeruvenu opened 2 months ago

thanneeruvenu commented 2 months ago

Expected Behaviour

Actual Behaviour

Reproduce Scenario (including but not limited to)

Steps to Reproduce

const proxyFetch = createFetch();

        const aemHeadlessClient = new AEMHeadless({
            serviceURL: ' ',
            endpoint: '/content/_cq_graphql/global/endpoint.json',
            fetch: proxyFetch,
            headers: {'content-type': 'application/json', 'accept': 'application/json'},
            // auth: ['admin', 'admin'],
            //auth: [AEM_USER, AEM_PASS],
            // headers: {'customerheadername': 'customerheadervalue'}
        });
        aemHeadlessClient.runQuery(`query homePageQueery {
            homepageFragmentList {
              items {
                _path
                title
              }
            }
          }`)
            .then(data => 

                console.log(data))
            .catch(e => 
                console.error(e))

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

AioCoreSDKError [AEMHeadlessError]: [AEMHeadless:REQUEST_ERROR] General Request error: originalFetch is not a function. code: 'REQUEST_ERROR', sdk: 'AEMHeadless',

easingthemes commented 1 month ago

fetch can be any custom valid implementation of fetch. Error is coming from

    try {
      response = await this.fetch(url, requestOptions, retryOptions)
    } catch (error) {
      // 1.1 Request error: general
      throw new REQUEST_ERROR({

which means that your custom proxyFetch is not a function.