This API provides you with the basic informations about countries (name, continent, iso2,iso3 , currencycode , and flags soon !)
https://worldapi.onrender.com/
Use AXIOS for better experience !
https://axios-http.com/docs/intronpm i --save axios
const axios = require('axios')
import axios from 'axios'
const myAPI = async () => {
const response = await axios.get("https://worldapi.onrender.com/")
.then((res: any) => {
return res.data
})
return response.WORLD
}
myAPI().then(
(res:any) =>{
console.log(res)
}
)
const myAPI = async (index, data) => {
const response = await axios.get(`https://worldapi.onrender.com/by?field=${index}&target=${data}`)
.then((res: any) => {
return res.data
})
return response.data
}
myAPI("name", "Morocco").then(
(res:any) =>{
console.log(res)
}
)
myAPI("iso1", "MA").then(
(res:any) =>{
console.log(res)
}
)
myAPI("iso2", "MAR").then(
(res:any) =>{
console.log(res)
}
)
const myAPI = async (index, data) => {
const response = await axios.get(`https://worldapi.onrender.com/by?field=${index}&target=${data}`)
.then((res: any) => {
return res.data
})
return response.datas
}
myAPI("currency", "EUR").then(
(res:any) =>{
console.log(res)
}
)
myAPI("continent", "Europe").then(
(res:any) =>{
console.log(res)
}
)