const axios = require('axios'); const newClient = ({ playerName, challengerURL }) => { const nextChallenge = (token) => axios ({ url: `${challengerURL}/api/challenge?token=${token}`, }) .then(({ data: { expr } }) => expr); const start = () => axios({ method: 'POST', url: `${challengerURL}/api/register`, headers: { 'Content-Type': 'application/json;charset=utf-8' }, data: playerName, }) .then(({ data }) => data); return { nextChallenge, start, }; }; module.exports = { newClient, };