From 8925cc1a8afeda7514dd38e2faf5bbef96458a9f Mon Sep 17 00:00:00 2001 From: Alessandro Casazza Date: Fri, 23 Aug 2024 11:46:45 +0200 Subject: [PATCH 1/2] Remove `axios` --- package.json | 1 - packages/react-components/package.json | 3 +-- .../src/context/ExternalFunctionContext.ts | 17 +++++++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ffbbd5f4..01073eca 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "overrides": { "postcss@<8.4.31": ">=8.4.31", "graphql@>=16.3.0 <16.8.1": ">=16.8.1", - "axios@>=0.8.1 <1.6.0": ">=1.6.0", "vite@>=4.4.0 <4.4.12": ">=4.4.12", "@babel/traverse@<7.23.2": ">=7.23.2", "vite@>=4.0.0 <=4.5.1": ">=4.5.2", diff --git a/packages/react-components/package.json b/packages/react-components/package.json index b21a9c0e..097917d4 100644 --- a/packages/react-components/package.json +++ b/packages/react-components/package.json @@ -185,7 +185,6 @@ "@stripe/stripe-js": "^4.3.0", "@tanstack/react-table": "^8.17.3", "@types/iframe-resizer": "^3.5.13", - "axios": "^1.7.3", "braintree-web": "^3.106.0", "frames-react": "^1.1.2", "iframe-resizer": "^4.4.5", @@ -225,4 +224,4 @@ "peerDependencies": { "react": ">=18.0.0" } -} +} \ No newline at end of file diff --git a/packages/react-components/src/context/ExternalFunctionContext.ts b/packages/react-components/src/context/ExternalFunctionContext.ts index 8110a6c6..c980f590 100644 --- a/packages/react-components/src/context/ExternalFunctionContext.ts +++ b/packages/react-components/src/context/ExternalFunctionContext.ts @@ -1,5 +1,4 @@ import { createContext } from 'react' -import axios from 'axios' interface Context { url: string | null @@ -14,7 +13,21 @@ type CallExternalFunction = (params: { export const callExternalFunction: CallExternalFunction = async ({ url, data -}) => await axios.post(url, data) +}) => { + const response = await fetch(url, { + method: 'POST', + body: JSON.stringify(data), + headers: { + 'Content-Type': 'application/json' + } + }) + + if (!response.ok) { + throw new Error('Failed to call external function') + } + + return await response.json() +} const ExternalFunctionContext = createContext({ url: null, From 467410c7645f688012dbd3420146fd74445023e1 Mon Sep 17 00:00:00 2001 From: Alessandro Casazza Date: Tue, 27 Aug 2024 11:56:56 +0200 Subject: [PATCH 2/2] Update deps --- pnpm-lock.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8317c148..98994cc7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,6 @@ settings: overrides: postcss@<8.4.31: '>=8.4.31' graphql@>=16.3.0 <16.8.1: '>=16.8.1' - axios@>=0.8.1 <1.6.0: '>=1.6.0' vite@>=4.4.0 <4.4.12: '>=4.4.12' '@babel/traverse@<7.23.2': '>=7.23.2' vite@>=4.0.0 <=4.5.1: '>=4.5.2' @@ -192,9 +191,6 @@ importers: '@types/iframe-resizer': specifier: ^3.5.13 version: 3.5.13 - axios: - specifier: ^1.7.3 - version: 1.7.4 braintree-web: specifier: ^3.106.0 version: 3.106.0 @@ -1518,7 +1514,7 @@ packages: resolution: {integrity: sha512-2D6y7fNvFmsLmRt6UCOFJPvFoPMJGT0Uh1Wg0RaigUp7kdQPs6yYn8Dmx6GZkOH/NW0yMTwRz/p0SRMMRo50vA==} peerDependencies: typescript: '>= 4.3.x' - vite: '>=5.1.7' + vite: '>=4.5.2' peerDependenciesMeta: typescript: optional: true @@ -2954,13 +2950,13 @@ packages: resolution: {integrity: sha512-AfgcRL8ZBhAlc3BFdigClmTUMISmmzHn7sB2h9U1odvc5U/MjWXsAaz18b/WoppUTDBzxOJwo2VdClfUcItu9g==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: - vite: '>=5.1.7' + vite: '>=4.5.2' '@vitejs/plugin-react@4.3.1': resolution: {integrity: sha512-m/V2syj5CuVnaxcUJOQRel/Wr31FFXRFlnOoq1TVtkCxsY5veGMTEmpWHndrhB2U8ScHtCQB1e+4hWYExQc6Lg==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: - vite: '>=4.5.2' + vite: '>=5.1.7' '@vitest/coverage-v8@2.0.5': resolution: {integrity: sha512-qeFcySCg5FLO2bHHSa0tAZAOnAUbp4L6/A5JDuj9+bt53JREl8hpLjLHEWF0e/gWc8INVpJaqA7+Ene2rclpZg==}