Skip to content

Commit

Permalink
feat: Implemented the send money fake API
Browse files Browse the repository at this point in the history
  • Loading branch information
Valsuh45 committed Mar 27, 2024
1 parent 115f0db commit e6ebc53
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions power-pay-frontend/src/components/okpage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
//faking the API
import React, { useEffect, useState } from 'react';
import axios from 'axios';

const OKpage: React.FC = () => {
const baseURL = 'http://localhost:5000'; // specifying the base URL with the desired port
const api = axios.create({
baseURL,
timeout: 5000,
});

// Mock function to simulate a succesful API call
const mockSend_MoneyAPI = async (
senderPhoneNumber: string,
recipientPhoneNumber: string,
amount: number
) => {
try {
const response = await api.post('/send_money', {
senderPhoneNumber,
recipientPhoneNumber,
amount });
return response.data;
} catch (error) {
throw error;
}
}

// Handle API call when component mounts
useEffect(() => {
mockSend_MoneyAPI('12347656', '1234567890', 100)
.then((response) => {
console.log("Mock API Response", response);
})
.catch((error) => {
console.error("Mock API Error", error);
});
}, []);
}

//building the ok page for successful transfer
const OKPage = () => {
Expand Down

0 comments on commit e6ebc53

Please sign in to comment.