Skip to content

Commit

Permalink
[Finishes #26] API is not supported anymore #27
Browse files Browse the repository at this point in the history
# Story Title

[API is not supported anymore](#26)

## Changes made

* fix: replace API with a new one

## How does the solution address the problem

This PR will replace [the original API](https://github.com/apilayer/restcountries), which [no longer works and is not supported](apilayer/restcountries#253), with [a similar one](https://gitlab.com/amatos/rest-countries) based on a clone of the original.

## Linked issues

Resolves #26
  • Loading branch information
mateuszdomagala authored Jan 12, 2022
1 parent 58ddf24 commit 6a036ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default {
border: 0;
background-color: inherit;
color: inherit;
width: 80%;
outline: 0;
}
@media (min-width: 660px) {
Expand Down
6 changes: 3 additions & 3 deletions src/views/CountryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export default {
onMounted(async () => {
try {
const countryResponse = await fetch(`https://restcountries.eu/rest/v2/name/${props.name}?fields=name;nativeName;population;region;subregion;capital;topLevelDomain;currencies;languages;borders;flag`)
const countryResponse = await fetch(`https://restcountries.com/v2/name/${props.name}?fields=name,nativeName,population,region,subregion,capital,topLevelDomain,currencies,languages,borders,flag`)
country.value = await countryResponse.json()
country.value = country.value[0]
alpha3Codes.value = country.value.borders.join(';')
alpha3Codes.value = country.value.borders.join(',')
const bordersResponse = await fetch(`https://restcountries.eu/rest/v2/alpha?codes=${alpha3Codes.value}`)
const bordersResponse = await fetch(`https://restcountries.com/v2/alpha?codes=${alpha3Codes.value}`)
borderCountries.value = await bordersResponse.json()
} catch(e) {
error.value = e
Expand Down
2 changes: 1 addition & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
onMounted(async () => {
try {
const res = await fetch('https://restcountries.eu/rest/v2/all?fields=name;capital;region;population;flag;alpha3Code')
const res = await fetch('https://restcountries.com/v2/all?fields=name,capital,region,population,flag,alpha3Code')
countries.value = await res.json()
} catch(e) {
error.value = e
Expand Down

1 comment on commit 6a036ab

@vercel
Copy link

@vercel vercel bot commented on 6a036ab Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.