export async function call ( toPostalCode, fromPostalCode, authKey ) {
const baseUrl = "https://api.pro6pp.nl" ;
const encodedUrl = new URL( ` ${baseUrl} /v2/distance/ch` );
const queryParams = { toPostalCode : toPostalCode, fromPostalCode : fromPostalCode, authKey : authKey }
encodedUrl.search = new URLSearchParams(queryParams)
return await fetch(encodedUrl).catch( ( error ) => {
throw new Error (error);
});
}
call( "1012" , "1011" , "YOUR_API_KEY" )
.then( ( response ) => {
console .log(response.status);
return response.json();
})
.then( ( res ) => {
console .log(res);
});
import requests
def call ( to_postal_code, from_postal_code, auth_key ):
url = f"https://api.pro6pp.nl/v2/distance/ch?toPostalCode= {to_postal_code} &fromPostalCode= {from_postal_code} &authKey= {auth_key} "
try :
response = requests.get(url)
return response
except requests.exceptions.RequestException as e:
raise e
response = call( "1012" , "1011" , "YOUR_API_KEY" )
print (response.status_code)
print (response.json())