Blog

Posts written in March 2023.

  • Published on
    -
    3 min read

    Working From Home - A Three-Year Update

    It's 23rd March 2020 8:30pm and Boris has announced a stay-at-home order effective immediately. Absolutely befuddled at what is about to happen, I receive a call soon after the broadcast from my manager saying we should go to the office and collect any equipment that would allow us to start working from home.

    It is only after returning back from the office later that evening where it dawned on me that things have changed. Thoughts about health, family and concerns about my livelihood all of a sudden came into question. Uncertainty of life as we knew it.

    As strange as it may sound, my basic home office setup gave me a sense of focus, purpose and security. I consider myself as one of the lucky ones during the pandemic where I had a room that could act as a dedicated home office.

    The Very First Work From Office Setup

    Three years on I'm still happily working remotely. The only thing that has changed with each passing year since that fateful night is my office is better equipped and as of last year started making more of an effort in hybrid working by making appearances a couple times a week to my place of work. Being able to choose when to work from the office on my own terms gives me the freedom to break up the week and do find it refreshing. Best of both worlds!

    The pandemic was an uncontrollable force for change in many peoples lives and in my case, both personally and professionally. When I reflect back to the time before the pandemic, I often wonder how I was able to work around 47 hour week and yet still find time to cook, clean and relax. I can only surmise that this is all we have ever known and what was expected of us. A way of life ingrained in our DNA from the very moment we begin our careers.

    Productivity

    The pace of life has slowed to the point where, for the most part, I can schedule my working hours around my day. I now start my day earlier and undisturbed, allowing me to rip through emails and complete some tasks from the day before, all before my first meeting.

    I still work in a similar fashion to how I normally would do within an office environment where I am sat at my desk over many hours, but the main difference being - I have more time!

    I’m able to get personal mundane tasks done, such as putting the washing on, prepping healthy food (now completely handled by my wife), or even cleaning the bathroom during my lunch break. These types of tasks help get me away from the desk for small moments of time and be productive in doing so.

    Even though I've gone to a hybrid working pattern, there are stark differences between being at home and the office. Suffice to say I am more productive within a home environment as I'm able to focus on the job in hand without distractions (apart from a few scheduled meetings), which is a blessing as a programmer.

    There just doesn’t seem to be time to work in an office anymore on a full-time basis. Working from home has proved to be a positive change from both a work and personal perspective.

    Minor Downsides

    Working from home gives me a lot of flexibility in how I work. Sometimes too much flexibility can be a detriment to when you feel you can have a break. Some are able to walk away from their desk during lunchtime and stick to the 9 to 5. Unfortunately, I'm not the type of person who can do that.

    I find it quite difficult to set boundaries at home even though I have a dedicated working space. At least when working from the office, the day ends from the moment you leave the building.

    The Future and Sustainability

    Regardless what employers think of the work from home phenomenon, it isn’t going anywhere soon. It’s what future employees expect. If your job can be done at a desk, does it matter where your desk is?

    Since we've returned from post pandemic normality, I’ve become more conscious how professional myself and my surroundings may come across to new clients I talk to on Zoom calls and make an active effort in ensuring everything is up-to-par. - Some clients may interpret disturbances from family members and informal looking office surroundings as unprofessional.

    Conclusion

    Working from home is just a small part in a bigger picture on how the pandemic has changed my life. It was a catalyst of positive change that forced me to reassess my priorities.

    Home really is where the heart is and there is no longer any doubt whether work and family life are able to mix under one roof. I wouldn't have it any other way.

  • There are times when you need to call multiple API endpoints to return different data based on the same data structure. Normally, I'd go down the approach of manually creating multiple Axios GET requests and then inserting the endpoint responses into a single object array. But there is a more concise and readable way to handle such tasks.

    With the help of DummyJson.com, we will be using the product search endpoint to search for different products to consolidate into a single array of product objects: /products/search?q=.

    As you can see from the code below, we start off by populating an array with a list of API endpoints where multiple GET request can be carried out for each endpoint from our array. The requests variable contains an array of promises based on each of these GET requests.

    Finally, axios.all() allows us to to make multiple HTTP requests to our endpoints altogether. This function can only iterate through a collection of promises. For more information regarding this Axios function, I found the following article very insightful for a better understanding: Using axios.all to make concurrent requests.

    // List all endpoints.
    let endpoints = [
      'https://dummyjson.com/products/search?q=Laptop',
      'https://dummyjson.com/products/search?q=phone',
    ];
    
    // Perform a GET request on all endpoints.
    const requests = endpoints.map((url) => axios.get(url));
    
    // Loop through the requests and output the data.
    axios.all(requests).then((responses) => {
    	let data = [];
    
      responses.forEach((resp) => {
    	  data.push(...resp.data.products)
      });
      
      // Output consolidated array to the page.
      const template = $.templates("#js-product-template");
      const htmlOutput = template.render(data);
    
      $("#result").html(htmlOutput);
    });
    

    As we're looping through each request, we push the response to our data array. It is here where we merge all requests together into a single array of objects. To make things a little more easier to display the results to the page, I use the jsrender.js templating plugin.

    A working demo can be seen on JsFiddle.