-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api calls, currency conversion commit
- Loading branch information
Showing
5 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import axios from "axios"; | ||
|
||
const API_KEY = '4d100bb424mshaaaecf4bd1066f5p1b5cb0jsn7cc8632e6b51'; | ||
const BASE_URL = 'https://currency-converter-by-api-ninjas.p.rapidapi.com/v1/convertcurrency'; | ||
|
||
const exchRate_api = axios.create({ | ||
baseURL: BASE_URL, | ||
headers: { | ||
"x-rapidapi-host": 'currency-converter-by-api-ninjas.p.rapidapi.com', | ||
"x-rapidapi-key": API_KEY, | ||
}, | ||
params: {have: 'USD', want: 'INR', amount: '1'}, | ||
}); | ||
|
||
|
||
|
||
export default exchRate_api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useEffect, useState } from 'react' | ||
|
||
const CurrencyConvertor = () => { | ||
|
||
function CurrencyConverter() { | ||
|
||
const [exchangeRate, setExchangeRate] = useState(null); | ||
|
||
|
||
useEffect(() => { | ||
const fetchExchangeRate = async () => { | ||
const response = await fetch( 'https://currency-converter-by-api-ninjas.p.rapidapi.com/v1/convertcurrency'); | ||
const data = await response.json(); | ||
setExchangeRate(data.rate); | ||
} | ||
fetchExchangeRate(); | ||
}, []); | ||
} | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default CurrencyConvertor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters