const map = require('lodash/fp/map');
const pick = require('lodash/fp/pick');
const axios = require('axios');
const url = require('./config').mainEntryPoint;

module.exports = token => {
  return axios.get(`${url}/service`, { headers: { 'Fastly-Key': token } })
    .then(services => {
      return map(pick(['version', 'id']))(services.data);
    });
};

@@ -1,12 +1,27 @@
+'use strict';%0A%0A
 const map = 
@@ -124,19 +124,22 @@
 ;%0Aconst 
-url
+config
  = requi
@@ -156,23 +156,8 @@
 ig')
-.mainEntryPoint
 ;%0A%0Am
@@ -171,16 +171,22 @@
 xports =
+ async
  token =
@@ -195,31 +195,75 @@
 %7B%0A  
-return axios.get(%60$%7Burl
+try %7B%0A    const services = await axios.get(%60$%7Bconfig.mainEntryPoint
 %7D/se
@@ -311,35 +311,10 @@
 %7D %7D)
+;
 %0A
-    .then(services =%3E %7B%0A  
     
@@ -371,13 +371,91 @@
 ;%0A  
+%7D catch (e) %7B%0A    throw new Error(%60Unable to get services that use $%7Btoken%7D.%60);%0A
   %7D
-);
 %0A%7D;%0A

Refactor services.js with async/await