Skip to content

Commit

Permalink
fix: Connect KharCoin to Ton network And Save Wallet to backend database
Browse files Browse the repository at this point in the history
  • Loading branch information
Javid Momeni committed Jun 30, 2024
1 parent 48f71f7 commit 95d9afa
Showing 1 changed file with 42 additions and 18 deletions.
60 changes: 42 additions & 18 deletions src/pages/Boosts.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,49 @@ export function BoostsPage() {

useEffect(() => {
if (userFriendlyAddress) {
fetch('https://kharcoin.com/api/savewallet', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
id : usertgid,
wallet : userFriendlyAddress,
}),
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
// Handle success, e.g., show a message to the user


// fetch('https://kharcoin.com/api/savewallet', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// id : usertgid,
// wallet : userFriendlyAddress,
// }),
// })
// .then(response => response.json())
// .then(data => {
// console.log('Success:', data);
// // Handle success, e.g., show a message to the user
// })
// .catch((error) => {
// console.error('Error:', error);
// // Handle errors, e.g., show an error message to the user
// });

const formdata = new FormData();
console.log(String(usertgid));
formdata.append("wallet", userFriendlyAddress);
formdata.append("id", String(usertgid));

const requestOptions = {
method: "POST",
body: formdata,
};

fetch("https://kharapi.rahomaskan.com/api/savewallet", requestOptions)
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text(); // Assuming the response is text. Adjust accordingly.
})
.catch((error) => {
console.error('Error:', error);
// Handle errors, e.g., show an error message to the user
});
.then((result) => console.log(result))
.catch((error) => console.error(error));


}
}, [usertgid]);
return (
Expand Down

0 comments on commit 95d9afa

Please sign in to comment.