TypeError: Cannot read properties of undefined (reading 'Rest')

Hello,

When I trigger the following code to create an application charge, (a one-time payment that can be found in the documentation here https://shopify.dev/docs/api/admin-rest/2024-10/resources/applicationcharge#post-application-charges) :

import { DataType } from '@shopify/shopify-api';

const goToCheckout = async () => {
    const client = new shopify.clients.Rest({session});
      const data = await client.post({
      path: 'application_charges',
      data: {"application_charge":{
        "name":"Super Duper Expensive action",
        "price":100.0,
        "return_url":"http://super-duper.shopifyapps.com",
        "test":true}},
      type: DataType.JSON,
    });
  };

I get the following error:

“Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘Rest’) at goToCheckout (top-up.jsx:13:43) at onClick (top-up.jsx:179:32) at HTMLUnknownElement.callCallback2 (chunk-GZD7INZN.js?v=4c7f3d14:3674:22) at Object.invokeGuardedCallbackDev (chunk-GZD7INZN.js?v=4c7f3d14:3699:24) at invokeGuardedCallback (chunk-GZD7INZN.js?v=4c7f3d14:3733:39) at invokeGuardedCallbackAndCatchFirstError (chunk-GZD7INZN.js?v=4c7f3d14:3736:33) at executeDispatch (chunk-GZD7INZN.js?v=4c7f3d14:7014:11) at processDispatchQueueItemsInOrder (chunk-GZD7INZN.js?v=4c7f3d14:7034:15) at processDispatchQueue (chunk-GZD7INZN.js?v=4c7f3d14:7043:13) at dispatchEventsForPlugins (chunk-GZD7INZN.js?v=4c7f3d14:7051:11)”.

Thanks in advance.