Is ethers.js in cloud functions gone as of today?

I was using this beautifully well in cloud functions until today

const web3 = Moralis.ethersByChain(β€œ0x1”); 

Example of using ethersByChain has been gone from the v1docs for a while (not sure when/if it was removed) but you can use web3.js.

I can rewrite my cloud function code to use web3.js but what’s the syntax for getting a reference to web3.js in a cloud function? This and variations I’ve tried are failing.

    const web3 = new Moralis.Web3(
        new Moralis.Web3.providers.HttpProvider(
          "https://h2yoot4zcjng.usemoralis.com:2053/server"
        )
      );
web3 = new Moralis.Web3(
    new Moralis.Web3.providers.HttpProvider(
      "RPC URL"
    )
);

For that link, you put in an RPC URL for the chain you want to connect to, not the URL to your Moralis server.

For RPC URL, you can use a public one e.g. https://polygon-rpc.com for Polygon, or ideally one from a node provider like Chainstack.