From c36f4861004da341491105e6ac3933f553862477 Mon Sep 17 00:00:00 2001 From: praneeth-rdy Date: Sat, 7 Dec 2024 19:57:24 +0530 Subject: [PATCH] feat: replaced fetch with axios --- package.json | 1 + src/components/contact/ContactForm.js | 19 ++++++++---------- yarn.lock | 28 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index aedafb07..630721a3 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "url": "https://github.com/praneeth-rdy/praneeth-rdy.github.io/issues" }, "dependencies": { + "axios": "^1.7.9", "gatsby": "3.14.6", "gatsby-plugin-feed": "3.14.0", "gatsby-plugin-google-analytics": "3.14.0", diff --git a/src/components/contact/ContactForm.js b/src/components/contact/ContactForm.js index 0f0188fe..65619810 100644 --- a/src/components/contact/ContactForm.js +++ b/src/components/contact/ContactForm.js @@ -2,7 +2,7 @@ import React, { useState } from "react" // import Img from "gatsby-image" // import { GatsbyImage } from "gatsby-plugin-image" // import { FaEnvelope, FaFacebook, FaGithub, FaLinkedin } from "react-icons/fa" -// import axios from "axios"; +import axios from "axios" import "../../styles/css/screens/contact.css" import { graphql, StaticQuery } from "gatsby" @@ -31,20 +31,17 @@ function ContactForm({ data, darkMode }) { hour12: true, }), } - const requestOptions = { - method: "POST", - mode: "no-cors", + + axios({ + method: "post", + url: + "https://script.google.com/macros/s/AKfycbzeRvT-r_rDE339RLL6KiZju06EZSrocF1rV8YepXb3X_RPg27KoJ1nwwFsPAXRhEjlEQ/exec", + data: new URLSearchParams(formData).toString(), headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json", }, - body: new URLSearchParams(formData).toString(), - } - - fetch( - "https://script.google.com/macros/s/AKfycbzeRvT-r_rDE339RLL6KiZju06EZSrocF1rV8YepXb3X_RPg27KoJ1nwwFsPAXRhEjlEQ/exec", - requestOptions - ) + }) .then(response => { setFormStatusMessage("Form submitted successfully") }) diff --git a/yarn.lock b/yarn.lock index 76bc243b..44ec9e76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2667,6 +2667,15 @@ axios@^0.21.1, axios@^0.21.4: dependencies: follow-redirects "^1.14.0" +axios@^1.7.9: + version "1.7.9" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.9.tgz#d7d071380c132a24accda1b2cfc1535b79ec650a" + integrity sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + axobject-query@^2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz" @@ -5209,6 +5218,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0: resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz" integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== +follow-redirects@^1.15.6: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + for-in@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz" @@ -5245,6 +5259,15 @@ form-data@^3.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +form-data@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.1.tgz#ba1076daaaa5bfd7e99c1a6cb02aa0a5cff90d48" + integrity sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz" @@ -10028,6 +10051,11 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.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== + pseudomap@^1.0.1, pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz"