Skip to content

Commit

Permalink
Update Hello.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Divya4242 authored Mar 27, 2024
1 parent 4d241ae commit 45b9716
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions client/src/Hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ const Hello = () => {
}
};

// const sub = async () => {
// try {
// const response = await fetch('http://65.1.248.118:5000/sub',{
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify({"num1": Number(num1), "num2": Number(num2)})
// });
// const data = await response.json()
// if(data.result){
// SetAns(data.result)
// }
// } catch (error) {
// console.error(error)
// }
// };
const sub = async () => {
try {
const response = await fetch('http://65.1.248.118:5000/sub',{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({"num1": Number(num1), "num2": Number(num2)})
});
const data = await response.json()
if(data.result){
SetAns(data.result)
}
} catch (error) {
console.error(error)
}
};
return (
<>
<input
Expand Down Expand Up @@ -63,6 +63,15 @@ const Hello = () => {
>
Sum
</button>
<button
type="submit"
onClick={(e) => {
sub(e);
}}
className="btn btn-primary btn-block mb-3 "
>
Subtraction
</button>
<h2>Ans {ans}</h2>
</>
);
Expand Down

0 comments on commit 45b9716

Please sign in to comment.