How to make an http call from an Atlas function?


I cannot find any information anywhere on how to make an http call from within a MongoDB Atlas function. Here’s what I have tried so far:

  • node-fetch - fails installation, cannot add to the dependencies list.
  • axios - idem.
  • I found some vague mentions of MongoDB Atlas providing its own http library and I have tried the following to import it:
    const http ="http");
    This has failed with an error: Error: Cannot access member 'get' of undefined

Nothing else comes to mind. So how to make an http request from a MongoDB Atlas function?

Hi @Vladimir,

The error is being returned because the method is deprecated.

Does the following work for you instead :



Thank you very much Jason!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.