This is taken from our getting started guide, specifically: “Working with REST Datasources“. It displays the countries for a given regional_bloc. Documentation: https://restcountries.eu/#api-endpoints-regional-bloc

Preview

Datasource

Field

Value

Name

REST Countries

Type

REST Custom

URL

https://restcountries.eu/rest/v2

Converter

Field

Value

Name

REST Countries Filter

Content

function convert(json) {
  return JSON.parse(json).map(country => {
	return {
	  'Flag': country.flag,
	  'Name': country.name,
	  'Code': country.alpha2Code,
	  'Capital': country.capital,
	  'Population': country.population
	}
  });
}
CODE

Template

Field

Value

Name

REST Countries Flags

Content

#set($tableRows = $PQ.toList($result))
#set($tableHeaders = $tableRows.get(0).keySet())
<table class="aui">
  <thead>
    <tr>
      #foreach ($header in $tableHeaders)
        <th>$!header</th>
      #end
    </tr>
  </thead>
  <tbody>
    #foreach ($row in $tableRows)
      <tr>
	  	<td><img src="$row.Flag" height="20" /></td>
		<td>$row.Name</td>
		<td>$row.Code</td>
		<td>$row.Capital</td>
		<td>$row.Population</td>
      </tr>
    #end
  </tbody>
</table>
CODE

Query

Field

Value

Name

Countries per region

Datasource

REST Countries

Template

REST Countries Flags

Converter

REST Countries Filter

REST URL

/region/:region

Example values for the region parameter:

  • Africa

  • Americas

  • Asia

  • Europe

  • Oceania