Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

realFetch.call is not a function #125

Closed
joernroeder opened this issue Nov 3, 2021 · 1 comment
Closed

realFetch.call is not a function #125

joernroeder opened this issue Nov 3, 2021 · 1 comment

Comments

@joernroeder
Copy link

I'm running into a seemingly know issue when using the dato client inside a gatsby function

I'm not only seeing it on gatsby cloud but also in my local environment and the reason for that seems to be matthew-andrews/isomorphic-fetch#194 (comment). There is also a potential simple fix around for some while matthew-andrews/isomorphic-fetch#195 but the approach users are taking currently is using https://www.npmjs.com/package/cross-fetch instead.

// src/api/hello-get-upload-url.js

import { SiteClient } from "datocms-client"

const client = new SiteClient(process.env.DATO_CMS_TOKEN)

export default function handler(req, res) {
  if (req.method !== 'POST') {
    return res.status(405).send()
  }

  // request a new upload url
  client.uploadRequest.create({
    filename: 'foo.jpg',
  }).then((uploadRequest) => {
    console.log(uploadRequest);
    res.status(200).json(uploadRequest);
  })
  .catch((error) => {
    console.error(error);
    res.status(400).send();
  });
}
@stefanoverna
Copy link
Member

Please try with 3.5.9 which uses cross-fetch! Thanks for reporting @joernroeder!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants