// Route prerequisites support both sync and async // operations. The reply interface in the handler // won't be called until this request is fulfilled const getGithubImage = (request, reply) => { const slug = request.params.slug; const githubUser = instructorsData.find( instructor => instructor.slug == slug ).github; const options = { headers: { 'User-Agent': 'fem-instructors-api' }, json: true }; Wreck.get( `https://api.github.com/users/${githubUser}`, options, (error, response, payload) => { if (error) return reply(Boom.badRequest(error)); reply(payload.avatar_url); } ); }