A Quick API for 4

Based on my earlier story about the magic of the number 4, I put together two things this evening. First, an API that takes a GET request with a number and returns back the list of numbers to get to 4. Second, a VueJS front end using axios to perform the API call when a user inputs a number and presses Compute. Screenshot below with the number 2000 as an input.

Had some trouble with CORS…. but managed to figure out the required middleware in Express, shown below.

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

Now I just need to figure out a nice visual representation for this data. I’m thinking about a 10x10 box of numbers and some graphical way of showing each number’s path back to the number 4.