export async function call ( postalCode, settlement, street, streetNumber, authKey ) {
const baseUrl = "https://api.pro6pp.nl" ;
const encodedUrl = new URL( ` ${baseUrl} /v2/autocomplete/ch` );
const queryParams = { postalCode : postalCode, settlement : settlement, street : street, streetNumber : streetNumber, authKey : authKey }
encodedUrl.search = new URLSearchParams(queryParams)
return await fetch(encodedUrl).catch( ( error ) => {
throw new Error (error);
});
}
call( "5600" , "Lenzburg" , "Bifang" , "1" , "YOUR_API_KEY" )
.then( ( response ) => {
console .log(response.status);
return response.json();
})
.then( ( res ) => {
console .log(res);
});
import requests
def call ( postal_code, settlement, street, street_number, auth_key ):
url = f"https://api.pro6pp.nl/v2/autocomplete/ch?postalCode= {postal_code} &settlement= {settlement} &street= {street} &streetNumber= {street_number} &authKey= {auth_key} "
try :
response = requests.get(url)
return response
except requests.exceptions.RequestException as e:
raise e
response = call( "5600" , "Lenzburg" , "Bifang" , "1" , "YOUR_API_KEY" )
print (response.status_code)
print (response.json())