Skip to content

Commit

Permalink
Merge pull request #21 from yhoungdev/dev
Browse files Browse the repository at this point in the history
feat: created helper function for request
  • Loading branch information
yhoungdev authored Oct 18, 2022
2 parents 19d3d42 + 95dc9ea commit 3614247
Show file tree
Hide file tree
Showing 4 changed files with 892 additions and 23 deletions.
37 changes: 37 additions & 0 deletions helper/Request.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axios from "axios";
import { toast } from "react-toastify";


interface Props {
url?: any;
payload?: any;
}


const defaultUrl = 'http://localhost:5500/api'

export const Post = async ({url}: Props) => {

try {

const request = await axios.post(`${defaultUrl}${url}`);

} catch (error) {
console.log(error);
}


}

//function to get request
export const Get = async ({url}: Props) => {

try {

const request = axios.get(`${defaultUrl}${url}`);

} catch ( error ) {
console.log(error)
}

}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
"@chakra-ui/react": "^2.3.2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"axios": "^1.1.3",
"copy-to-clipboard": "^3.3.2",
"cypress": "^10.10.0",
"ethereum-blockies-base64": "^1.0.2",
"ethereum-blockies-png": "^0.1.3",
"ethers": "^5.7.1",
"framer-motion": "^6",
"moment": "^2.29.4",
"next": "12.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
25 changes: 15 additions & 10 deletions pages/Auth/CreateUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { useEffect, useState } from "react";
import copy from "copy-to-clipboard";
import { ToastContainer, toast } from "react-toastify";

const CreateUser = () => {
const [address, setAddress] = useState<any>();
const [phrase, setPhrase] = useState<any>([]);
const CreateUser =() => {

const [ address , setAddress ] = useState <any>();
const [ phrase , setPhrase ] = useState<any>([]);

const blockchainIdentity = async () => {
const wallet = ethers.Wallet.createRandom();
Expand All @@ -31,13 +32,17 @@ const CreateUser = () => {
blockchainIdentity();
}, []);

const copyToClipBoard = () => {
//copy mnemonic phrase
copy(phrase);
toast.success(" Copied to clipboard successfully ", {
theme: "colored",
});
};

const copyToClipBoard =() => {
//copy mnemonic phrase
copy(phrase);
toast.success(' Copied to clipboard successfully ', {
theme:'colored'
})

}



return (
<>
Expand Down
Loading

0 comments on commit 3614247

Please sign in to comment.