/
Javascript example code

Javascript example code

The following example retrieves a token and requests the list of service locations accessible to the current account:

(make sure to replace the credentials with your own!)

var test = async () => { let formData = new URLSearchParams(); formData.append('grant_type', 'password'); formData.append('username', '{{username}}'); formData.append('password', '{{password}}'); formData.append('client_id', '{{client_id}}); formData.append('client_secret', '{{client_secret}}'); const tokens = await fetch('https://farm1pub.smappee.net/dev/v3/oauth2/token', { method: 'POST', body: formData }) .then(response => response.json()); const accessToken = tokens.access_token; const result = await fetch('https://farm1pub.smappee.net/dev/v3/servicelocation', { headers: { Authorization: 'Bearer ' + accessToken } }) .then(response => response.json()); console.log(result); }; test();

 

Related content

Get Servicelocation Info
Get Servicelocation Info
More like this
Get Servicelocations
Get Servicelocations
More like this
Refresh token
Refresh token
Read with this
Create service location
Create service location
More like this
Set the charging mode of one of the connectors of a charging station
Set the charging mode of one of the connectors of a charging station
Read with this
Share access to service location
Share access to service location
More like this