Skip to content

Commit

Permalink
chore: remove axios
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Dec 21, 2023
1 parent 37a9195 commit 59d3785
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 71 deletions.
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-qr-code": "^2.0.12",
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/context/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
useState,
} from "react";
import { InfoResponse, UserInfo } from "../types";
import axios from "axios";

interface UserContextType {
info: UserInfo | null;
Expand All @@ -22,7 +21,7 @@ export function UserProvider({ children }: { children: React.ReactNode }) {

const logout = async () => {
try {
await axios.get('/logout');
await fetch('/logout');
} catch (error) {
// TODO: Handle failure
console.error('Error during logout:', error);
Expand All @@ -32,8 +31,8 @@ export function UserProvider({ children }: { children: React.ReactNode }) {

const getInfo = async () => {
try {
const response = await axios.get('/api/info');
const data: InfoResponse = response.data;
const response = await fetch('/api/info');
const data: InfoResponse = await response.json();
setInfo(data);
} catch (error) {
console.error('Error getting user info:', error);
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/screens/apps/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useNavigate } from 'react-router-dom';

import Loading from '../../components/Loading';
import { App, NostrEvent, ListAppsResponse } from "../../types";
import axios from "axios";

function Connections() {
const [apps, setApps] = useState<App[] | null>(null);
Expand All @@ -19,8 +18,8 @@ function Connections() {
useEffect(() => {
const fetchAppsData = async () => {
try {
const response = await axios.get("/api/apps");
const data: ListAppsResponse = response.data;
const response = await fetch("/api/apps");
const data: ListAppsResponse = await response.json();
setApps(data.apps);
setEventsCounts(data.eventsCounts);
setLastEvents(data.lastEvent);
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/screens/apps/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useUser } from '../../context/UserContext';
import { BudgetRenewalType, RequestMethodType, User, UserInfo, nip47MethodDescriptions, nip47MethodIcons, validBudgetRenewals } from '../../types';
import axios from 'axios';

const New = () => {
const { info } = useUser();
Expand Down Expand Up @@ -83,7 +82,13 @@ const New = () => {
formData.append("returnTo", returnTo);
formData.append("_csrf", info.csrf);
try {
const response = await axios.post("/api/apps", formData)
const response = await fetch("/api/apps", {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify(formData.toString()),
})
console.log(response)
// TODO: Navigate to success screen with data
// navigate("/apps/success");
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/screens/apps/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useState, useEffect } from 'react';
import { ShowAppResponse } from '../../types';
import Loading from '../../components/Loading';
import { useNavigate, useParams } from 'react-router-dom';
import axios from 'axios';
import { useUser } from '../../context/UserContext';

function Show() {
Expand All @@ -18,7 +17,13 @@ function Show() {
formData.append("_csrf", info.csrf);
try {
// Here you'd handle form submission. For example:
await axios.post(`/api/apps/delete/${appData.app.nostrPubkey}`, formData)
await fetch(`/api/apps/delete/${appData.app.nostrPubkey}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify(formData.toString()),
})
navigate("/apps?q=appdeleted");
} catch (error) {
console.error('Error deleting app:', error);
Expand All @@ -28,8 +33,8 @@ function Show() {
useEffect(() => {
const fetchAppData = async () => {
try {
const response = await axios.get(`/api/apps/${pubkey}`);
const data: ShowAppResponse = response.data;
const response = await fetch(`/api/apps/${pubkey}`);
const data: ShowAppResponse = await response.json();
setAppData(data);
} catch (error) {
console.error('Error fetching app data:', error);
Expand Down
57 changes: 0 additions & 57 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,6 @@ array-union@^2.1.0:
resolved "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz"
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

autoprefixer@^10.4.16:
version "10.4.16"
resolved "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.16.tgz"
Expand All @@ -536,15 +531,6 @@ autoprefixer@^10.4.16:
picocolors "^1.0.0"
postcss-value-parser "^4.2.0"

axios@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2"
integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"
Expand Down Expand Up @@ -630,13 +616,6 @@ color-name@~1.1.4:
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"

commander@^4.0.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
Expand Down Expand Up @@ -678,11 +657,6 @@ deep-is@^0.1.3:
resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz"
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==

delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

didyoumean@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037"
Expand Down Expand Up @@ -919,20 +893,6 @@ flatted@^3.2.9:
resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz"
integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==

follow-redirects@^1.15.0:
version "1.15.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

fraction.js@^4.3.6:
version "4.3.7"
resolved "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz"
Expand Down Expand Up @@ -1210,18 +1170,6 @@ micromatch@^4.0.4, micromatch@^4.0.5:
braces "^3.0.2"
picomatch "^2.3.1"

[email protected]:
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==

mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
dependencies:
mime-db "1.52.0"

mini-svg-data-uri@^1.2.3:
version "1.4.4"
resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939"
Expand Down Expand Up @@ -1443,11 +1391,6 @@ prop-types@^15.8.1:
object-assign "^4.1.1"
react-is "^16.13.1"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

punycode@^2.1.0:
version "2.3.1"
resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz"
Expand Down

0 comments on commit 59d3785

Please sign in to comment.