Skip to main content
Skip table of contents

[REST Custom] Countries with Flags

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.com/v3.1

Converter

Field

Value

Name

REST Countries Filter

Content

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

Template

Field

Value

Name

REST Countries Flags

Content

CODE
#set($tableRows = $PQ.toList($result))
<table class="aui">
  <thead>
    <tr>
		<th>Flag</th>
		<th>Name</th>
		<th>Code</th>
		<th>Capital</th>
		<th>Population</th>
    </tr>
  </thead>
  <tbody>
    #foreach ($row in $tableRows)
      <tr>
	  	<td>$row.Flag</td>
		<td>$row.Name</td>
		<td>$row.Code</td>
		<td>$row.Capital</td>
		<td>$row.Population</td>
      </tr>
    #end
  </tbody>
</table>

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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.