function writeData (data) { const serializer = Piloted.service('serializer'); if (!serializer) { console.error('Serializer not found'); return setTimeout(() => { writeData(data); }, 1000); } Wreck.post(`http://${serializer.address}:${serializer.port}/write/${internals.type}`, { payload: data }, (err) => { if (err) { console.error(err); } }); }
// 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); } ); }
cacheHeader = Wreck.parseCacheControl(response.headers['cache-control']);