Integrity
Write
Loading...
The woman

The woman

2 years ago

Because he worked on his side projects during working hours, my junior was fired and sued.

More on Entrepreneurship/Creators

Esteban

Esteban

2 years ago

The Berkus Startup Valuation Method: What Is It?

What Is That?

Berkus is a pre-revenue valuation method based exclusively on qualitative criteria, like Scorecard.

Few firms match their financial estimates, especially in the early stages, so valuation methodologies like the Berkus method are a good way to establish a valuation when the economic measures are not reliable.

How does it work?

This technique evaluates five key success factors.

  • Fundamental principle

  • Technology

  • Execution

  • Strategic alliances in its primary market

  • Production, followed by sales

The Berkus technique values the business idea and four success factors. As seen in the matrix below, each of these dimensions poses a danger to the startup's success.

It assigns $0-$500,000 to each of these beginning regions. This approach enables a maximum $2.5M pre-money valuation.

This approach relies significantly on geography and uses the US as a baseline, as it differs in every country in Europe.

A set of standards for analyzing each dimension individually

Fundamental principle (or strength of the idea)

Ideas are worthless; execution matters. Most of us can relate to seeing a new business open in our area or a startup get funded and thinking, "I had this concept years ago!" Someone did it.

The concept remains. To assess the idea's viability, we must consider several criteria.

  • The concept's exclusivity It is necessary to protect a product or service's concept using patents and copyrights. Additionally, it must be capable of generating large profits.

  • Planned growth and growth that goes in a specific direction have a lot of potential, therefore incorporating them into a business is really advantageous.

  • The ability of a concept to grow A venture's ability to generate scalable revenue is a key factor in its emergence and continuation. A startup needs a scalable idea in order to compete successfully in the market.

  • The attraction of a business idea to a broad spectrum of people is significantly influenced by the current socio-political climate. Thus, the requirement for the assumption of conformity.

  • Concept Validation Ideas must go through rigorous testing with a variety of audiences in order to lower risk during the implementation phase.

Technology (Prototype)

This aspect reduces startup's technological risk. How good is the startup prototype when facing cyber threats, GDPR compliance (in Europe), tech stack replication difficulty, etc.?

Execution

Check the management team's efficacy. A potential angel investor must verify the founders' experience and track record with previous ventures. Good leadership is needed to chart a ship's course.

Strategic alliances in its primary market

Existing and new relationships will play a vital role in the development of both B2B and B2C startups. What are the startup's synergies? potential ones?

Production, followed by sales (product rollout)

Startup success depends on its manufacturing and product rollout. It depends on the overall addressable market, the startup's ability to market and sell their product, and their capacity to provide consistent, high-quality support.

Example

We're now founders of EyeCaramba, a machine vision-assisted streaming platform. My imagination always goes to poor puns when naming a startup.

Since we're first-time founders and the Berkus technique depends exclusively on qualitative methods and the evaluator's skill, we ask our angel-investor acquaintance for a pre-money appraisal of EyeCaramba.

Our friend offers us the following table:

Because we're first-time founders, our pal lowered our Execution score. He knows the idea's value and that the gaming industry is red-hot, with worse startup ideas getting funded, therefore he gave the Basic value the highest value (idea).

EyeCaramba's pre-money valuation is $400,000 + $250,000 + $75,000 + $275,000 + $164,000 (1.16M). Good.

References

  • https://medium.com/humble-ventures/how-angel-investors-value-pre-revenue-startups-part-iii-8271405f0774#:~:text=pre%2Drevenue%20startups.-,Berkus%20Method,potential%20of%20the%20idea%20itself.%E2%80%9D

  • https://eqvista.com/berkus-valuation-method-for-startups/

  • https://www.venionaire.com/early-stage-startup-valuation-part-2-the-berkus-method/

Sanjay Priyadarshi

Sanjay Priyadarshi

2 years ago

Using Ruby code, a programmer created a $48,000,000,000 product that Elon Musk admired.

Unexpected Success

Photo of Tobias Lutke from theglobeandmail

Shopify CEO and co-founder Tobias Lutke. Shopify is worth $48 billion.

World-renowned entrepreneur Tobi

Tobi never expected his first online snowboard business to become a multimillion-dollar software corporation.

Tobi founded Shopify to establish a 20-person company.

The publicly traded corporation employs over 10,000 people.

Here's Tobi Lutke's incredible story.

Elon Musk tweeted his admiration for the Shopify creator.

30-October-2019.

Musk praised Shopify founder Tobi Lutke on Twitter.

Happened:

Screenshot by Author

Explore this programmer's journey.

What difficulties did Tobi experience as a young child?

Germany raised Tobi.

Tobi's parents realized he was smart but had trouble learning as a toddler.

Tobi was learning disabled.

Tobi struggled with school tests.

Tobi's learning impairments were undiagnosed.

Tobi struggled to read as a dyslexic.

Tobi also found school boring.

Germany's curriculum didn't inspire Tobi's curiosity.

“The curriculum in Germany was taught like here are all the solutions you might find useful later in life, spending very little time talking about the problem…If I don’t understand the problem I’m trying to solve, it’s very hard for me to learn about a solution to a problem.”

Studying computer programming

After tenth grade, Tobi decided school wasn't for him and joined a German apprenticeship program.

This curriculum taught Tobi software engineering.

He was an apprentice in a small Siemens subsidiary team.

Tobi worked with rebellious Siemens employees.

Team members impressed Tobi.

Tobi joined the team for this reason.

Tobi was pleased to get paid to write programming all day.

His life could not have been better.

Devoted to snowboarding

Tobi loved snowboarding.

He drove 5 hours to ski at his folks' house.

His friends traveled to the US to snowboard when he was older.

However, the cheap dollar conversion rate led them to Canada.

2000.

Tobi originally decided to snowboard instead than ski.

Snowboarding captivated him in Canada.

On the trip to Canada, Tobi encounters his wife.

Tobi meets his wife Fiona McKean on his first Canadian ski trip.

They maintained in touch after the trip.

Fiona moved to Germany after graduating.

Tobi was a startup coder.

Fiona found work in Germany.

Her work included editing, writing, and academics.

“We lived together for 10 months and then she told me that she need to go back for the master's program.”

With Fiona, Tobi immigrated to Canada.

Fiona invites Tobi.

Tobi agreed to move to Canada.

Programming helped Tobi move in with his girlfriend.

Tobi was an excellent programmer, therefore what he did in Germany could be done anywhere.

He worked remotely for his German employer in Canada.

Tobi struggled with remote work.

Due to poor communication.

No slack, so he used email.

Programmers had trouble emailing.

Tobi's startup was developing a browser.

After the dot-com crash, individuals left that startup.

It ended.

Tobi didn't intend to work for any major corporations.

Tobi left his startup.

He believed he had important skills for any huge corporation.

He refused to join a huge corporation.

Because of Siemens.

Tobi learned to write professional code and about himself while working at Siemens in Germany.

Siemens culture was odd.

Employees were distrustful.

Siemens' rigorous dress code implies that the corporation doesn't trust employees' attire.

It wasn't Tobi's place.

“There was so much bad with it that it just felt wrong…20-year-old Tobi would not have a career there.”

Focused only on snowboarding

Tobi lived in Ottawa with his girlfriend.

Canada is frigid in winter.

Ottawa's winters last.

Almost half a year.

Tobi wanted to do something worthwhile now.

So he snowboarded.

Tobi began snowboarding seriously.

He sought every snowboarding knowledge.

He researched the greatest snowboarding gear first.

He created big spreadsheets for snowboard-making technologies.

Tobi grew interested in selling snowboards while researching.

He intended to sell snowboards online.

He had no choice but to start his own company.

A small local company offered Tobi a job.

Interested.

He must sign papers to join the local company.

He needed a work permit when he signed the documents.

Tobi had no work permit.

He was allowed to stay in Canada while applying for permanent residency.

“I wasn’t illegal in the country, but my state didn’t give me a work permit. I talked to a lawyer and he told me it’s going to take a while until I get a permanent residency.”

Tobi's lawyer told him he cannot get a work visa without permanent residence.

His lawyer said something else intriguing.

Tobis lawyer advised him to start a business.

Tobi declined this local company's job offer because of this.

Tobi considered opening an internet store with his technical skills.

He sold snowboards online.

“I was thinking of setting up an online store software because I figured that would exist and use it as a way to sell snowboards…make money while snowboarding and hopefully have a good life.”

What brought Tobi and his co-founder together, and how did he support Tobi?

Tobi lived with his girlfriend's parents.

In Ottawa, Tobi encounters Scott Lake.

Scott was Tobis girlfriend's family friend and worked for Tobi's future employer.

Scott and Tobi snowboarded.

Tobi pitched Scott his snowboard sales software idea.

Scott liked the idea.

They planned a business together.

“I was looking after the technology and Scott was dealing with the business side…It was Scott who ended up developing relationships with vendors and doing all the business set-up.”

Issues they ran into when attempting to launch their business online

Neither could afford a long-term lease.

That prompted their online business idea.

They would open a store.

Tobi anticipated opening an internet store in a week.

Tobi seeks open-source software.

Most existing software was pricey.

Tobi and Scott couldn't afford pricey software.

“In 2004, I was sitting in front of my computer absolutely stunned realising that we hadn’t figured out how to create software for online stores.”

They required software to:

  • to upload snowboard images to the website.

  • people to look up the types of snowboards that were offered on the website. There must be a search feature in the software.

  • Online users transmit payments, and the merchant must receive them.

  • notifying vendors of the recently received order.

No online selling software existed at the time.

Online credit card payments were difficult.

How did they advance the software while keeping expenses down?

Tobi and Scott needed money to start selling snowboards.

Tobi and Scott funded their firm with savings.

“We both put money into the company…I think the capital we had was around CAD 20,000(Canadian Dollars).”

Despite investing their savings.

They minimized costs.

They tried to conserve.

No office rental.

They worked in several coffee shops.

Tobi lived rent-free at his girlfriend's parents.

He installed software in coffee cafes.

How were the software issues handled?

Tobi found no online snowboard sales software.

Two choices remained:

  1. Change your mind and try something else.

  2. Use his programming expertise to produce something that will aid in the expansion of this company.

Tobi knew he was the sole programmer working on such a project from the start.

“I had this realisation that I’m going to be the only programmer who has ever worked on this, so I don’t have to choose something that lots of people know. I can choose just the best tool for the job…There is been this programming language called Ruby which I just absolutely loved ”

Ruby was open-source and only had Japanese documentation.

Latin is the source code.

Tobi used Ruby twice.

He assumed he could pick the tool this time.

Why not build with Ruby?

How did they find their first time operating a business?

Tobi writes applications in Ruby.

He wrote the initial software version in 2.5 months.

Tobi and Scott founded Snowdevil to sell snowboards.

Tobi coded for 16 hours a day.

His lifestyle was unhealthy.

He enjoyed pizza and coke.

“I would never recommend this to anyone, but at the time there was nothing more interesting to me in the world.”

Their initial purchase and encounter with it

Tobi worked in cafes then.

“I was working in a coffee shop at this time and I remember everything about that day…At some time, while I was writing the software, I had to type the email that the software would send to tell me about the order.”

Tobi recalls everything.

He checked the order on his laptop at the coffee shop.

Pennsylvanian ordered snowboard.

Tobi walked home and called Scott. Tobi told Scott their first order.

They loved the order.

How were people made aware about Snowdevil?

2004 was very different.

Tobi and Scott attempted simple website advertising.

Google AdWords was new.

Ad clicks cost 20 cents.

Online snowboard stores were scarce at the time.

Google ads propelled the snowdevil brand.

Snowdevil prospered.

They swiftly recouped their original investment in the snowboard business because to its high profit margin.

Tobi and Scott struggled with inventories.

“Snowboards had really good profit margins…Our biggest problem was keeping inventory and getting it back…We were out of stock all the time.”

Selling snowboards returned their investment and saved them money.

They did not appoint a business manager.

They accomplished everything alone.

Sales dipped in the spring, but something magical happened.

Spring sales plummeted.

They considered stocking different boards.

They naturally wanted to add boards and grow the business.

However, magic occurred.

Tobi coded and improved software while running Snowdevil.

He modified software constantly. He wanted speedier software.

He experimented to make the software more resilient.

Tobi received emails requesting the Snowdevil license.

They intended to create something similar.

“I didn’t stop programming, I was just like Ok now let me try things, let me make it faster and try different approaches…Increasingly I got people sending me emails and asking me If I would like to licence snowdevil to them. People wanted to start something similar.”

Software or skateboards, your choice

Scott and Tobi had to choose a hobby in 2005.

They might sell alternative boards or use software.

The software was a no-brainer from demand.

Daniel Weinand is invited to join Tobi's business.

Tobis German best friend is Daniel.

Tobi and Scott chose to use the software.

Tobi and Scott kept the software service.

Tobi called Daniel to invite him to Canada to collaborate.

Scott and Tobi had quit snowboarding until then.

How was Shopify launched, and whence did the name come from?

The three chose Shopify.

Named from two words.

First:

  • Shop

Final part:

  • Simplify

Shopify

Shopify's crew has always had one goal:

  • creating software that would make it simple and easy for people to launch online storefronts.

Launched Shopify after raising money for the first time.

Shopify began fundraising in 2005.

First, they borrowed from family and friends.

They needed roughly $200k to run the company efficiently.

$200k was a lot then.

When questioned why they require so much money. Tobi told them to trust him with their goals. The team raised seed money from family and friends.

Shopify.com has a landing page. A demo of their goal was on the landing page.

In 2006, Shopify had about 4,000 emails.

Shopify rented an Ottawa office.

“We sent a blast of emails…Some people signed up just to try it out, which was exciting.”

How things developed after Scott left the company

Shopify co-founder Scott Lake left in 2008.

Scott was CEO.

“He(Scott) realized at some point that where the software industry was going, most of the people who were the CEOs were actually the highly technical person on the founding team.”

Scott leaving the company worried Tobi.

Tobis worried about finding a new CEO.

To Tobi:

A great VC will have the network to identify the perfect CEO for your firm.

Tobi started visiting Silicon Valley to meet with venture capitalists to recruit a CEO.

Initially visiting Silicon Valley

Tobi came to Silicon Valley to start a 20-person company.

This company creates eCommerce store software.

Tobi never wanted a big corporation. He desired a fulfilling existence.

“I stayed in a hostel in the Bay Area. I had one roommate who was also a computer programmer. I bought a bicycle on Craiglist. I was there for a week, but ended up staying two and a half weeks.”

Tobi arrived unprepared.

When venture capitalists asked him business questions.

He answered few queries.

Tobi didn't comprehend VC meetings' terminology.

He wrote the terms down and looked them up.

Some were fascinated after he couldn't answer all these queries.

“I ended up getting the kind of term sheets people dream about…All the offers were conditional on moving our company to Silicon Valley.”

Canada received Tobi.

He wanted to consult his team before deciding. Shopify had five employees at the time.

2008.

A global recession greeted Tobi in Canada. The recession hurt the market.

His term sheets were useless.

The economic downturn in the world provided Shopify with a fantastic opportunity.

The global recession caused significant job losses.

Fired employees had several ideas.

They wanted online stores.

Entrepreneurship was desired. They wanted to quit work.

People took risks and tried new things during the global slump.

Shopify subscribers skyrocketed during the recession.

“In 2009, the company reached neutral cash flow for the first time…We were in a position to think about long-term investments, such as infrastructure projects.”

Then, Tobi Lutke became CEO.

How did Tobi perform as the company's CEO?

“I wasn’t good. My team was very patient with me, but I had a lot to learn…It’s a very subtle job.”

2009–2010.

Tobi limited the company's potential.

He deliberately restrained company growth.

Tobi had one costly problem:

  • Whether Shopify is a venture or a lifestyle business.

The company's annual revenue approached $1 million.

Tobi battled with the firm and himself despite good revenue.

His wife was supportive, but the responsibility was crushing him.

“It’s a crushing responsibility…People had families and kids…I just couldn’t believe what was going on…My father-in-law gave me money to cover the payroll and it was his life-saving.”

Throughout this trip, everyone supported Tobi.

They believed it.

$7 million in donations received

Tobi couldn't decide if this was a lifestyle or a business.

Shopify struggled with marketing then.

Later, Tobi tried 5 marketing methods.

He told himself that if any marketing method greatly increased their growth, he would call it a venture, otherwise a lifestyle.

The Shopify crew brainstormed and voted on marketing concepts.

Tested.

“Every single idea worked…We did Adwords, published a book on the concept, sponsored a podcast and all the ones we tracked worked.”

To Silicon Valley once more

Shopify marketing concepts worked once.

Tobi returned to Silicon Valley to pitch investors.

He raised $7 million, valuing Shopify at $25 million.

All investors had board seats.

“I find it very helpful…I always had a fantastic relationship with everyone who’s invested in my company…I told them straight that I am not going to pretend I know things, I want you to help me.”

Tobi developed skills via running Shopify.

Shopify had 20 employees.

Leaving his wife's parents' home

Tobi left his wife's parents in 2014.

Tobi had a child.

Shopify has 80,000 customers and 300 staff in 2013.

Public offering in 2015

Shopify investors went public in 2015.

Shopify powers 4.1 million e-Commerce sites.

Shopify stores are 65% US-based.

It is currently valued at $48 billion.

Woo

Woo

2 years ago

How To Launch A Business Without Any Risk

> Say Hello To The Lean-Hedge Model

People think starting a business requires significant debt and investment. Like Shark Tank, you need a world-changing idea. I'm not saying to avoid investors or brilliant ideas.

Investing is essential to build a genuinely profitable company. Think Apple or Starbucks.

Entrepreneurship is risky because many people go bankrupt from debt. As starters, we shouldn't do it. Instead, use lean-hedge.

Simply defined, you construct a cash-flow business to hedge against long-term investment-heavy business expenses.

What the “fx!$rench-toast” is the lean-hedge model?

When you start a business, your money should move down, down, down, then up when it becomes profitable.

Example: Starbucks

Many people don't survive the business's initial losses and debt. What if, we created a cash-flow business BEFORE we started our Starbucks to hedge against its initial expenses?

Cash Flow business hedges against

Lean-hedge has two sections. Start a cash-flow business. A cash-flow business takes minimal investment and usually involves sweat and time.

Let’s take a look at some examples:

A Translation company

Personal portfolio website (you make a site then you do cold e-mail marketing)

FREELANCE (UpWork, Fiverr).

Educational business.

Infomarketing. (You design a knowledge-based product. You sell the info).

Online fitness/diet/health coaching ($50-$300/month, calls, training plan)

Amazon e-book publishing. (Medium writers do this)

YouTube, cash-flow channel

A web development agency (I'm a dev, but if you're not, a graphic design agency, etc.) (Sell your time.)

Digital Marketing

Online paralegal (A million lawyers work in the U.S).

Some dropshipping (Organic Tik Tok dropshipping, where you create content to drive traffic to your shopify store instead of spend money on ads).

(Disclaimer: My first two cash-flow enterprises, which were language teaching, failed terribly. My translation firm is now booming because B2B e-mail marketing is easy.)

Crossover occurs. Your long-term business starts earning more money than your cash flow business.

My cash-flow business (freelancing, translation) makes $7k+/month.

I’ve decided to start a slightly more investment-heavy digital marketing agency

Here are the anticipated business's time- and money-intensive investments:

  1. ($$$) Top Front-End designer's Figma/UI-UX design (in negotiation)

  2. (Time): A little copywriting (I will do this myself)

  3. ($$) Creating an animated webpage with HTML (in negotiation)

  4. Backend Development (Duration) (I'll carry out this myself using Laravel.)

  5. Logo Design ($$)

  6. Logo Intro Video for $

  7. Video Intro (I’ll edit this myself with Premiere Pro)

etc.

Then evaluate product, place, price, and promotion. Consider promotion and pricing.

The lean-hedge model's point is:

Don't gamble. Avoid debt. First create a cash-flow project, then grow it steadily.

Check read my previous posts on “Nightmare Mode” (which teaches you how to make work as interesting as video games) and Why most people can't escape a 9-5 to learn how to develop a cash-flow business.

You might also like

Bart Krawczyk

Bart Krawczyk

2 years ago

Understanding several Value Proposition kinds will help you create better goods.

Fixing problems isn't enough.

Numerous articles and how-to guides on value propositions focus on fixing consumer concerns.

Contrary to popular opinion, addressing customer pain rarely suffices. Win your market category too.

Graphic provided by the author.

Core Value Statement

Value proposition usually means a product's main value.

Its how your product solves client problems. The product's core.

Graphic provided by the author.

Answering these questions creates a relevant core value proposition:

  • What tasks is your customer trying to complete? (Jobs for clients)

  • How much discomfort do they feel while they perform this? (pains)

  • What would they like to see improved or changed? (gains)

After that, you create products and services that alleviate those pains and give value to clients.

Value Proposition by Category

Your product belongs to a market category and must follow its regulations, regardless of its value proposition.

Creating a new market category is challenging. Fitting into customers' product perceptions is usually better than trying to change them.

New product users simplify market categories. Products are labeled.

Your product will likely be associated with a collection of products people already use.

Example: IT experts will use your communication and management app.

If your target clients think it's an advanced mail software, they'll compare it to others and expect things like:

  • comprehensive calendar

  • spam detectors

  • adequate storage space

  • list of contacts

  • etc.

If your target users view your product as a task management app, things change. You can survive without a contact list, but not status management.

Graphic provided by the author.

Find out what your customers compare your product to and if it fits your value offer. If so, adapt your product plan to dominate this market. If not, try different value propositions and messaging to put the product in the right context.

Finished Value Proposition

A comprehensive value proposition is when your solution addresses user problems and wins its market category.

Graphic provided by the author.

Addressing simply the primary value proposition may produce a valuable and original product, but it may struggle to cross the chasm into the mainstream market. Meeting expectations is easier than changing views.

Without a unique value proposition, you will drown in the red sea of competition.

To conclude:

  1. Find out who your target consumer is and what their demands and problems are.

  2. To meet these needs, develop and test a primary value proposition.

  3. Speak with your most devoted customers. Recognize the alternatives they use to compare you against and the market segment they place you in.

  4. Recognize the requirements and expectations of the market category.

  5. To meet or surpass category standards, modify your goods.

Great products solve client problems and win their category.

Emma Jade

Emma Jade

2 years ago

6 hacks to create content faster

Content gurus' top time-saving hacks.

6 hacks to create content faster

I'm a content strategist, writer, and graphic designer. Time is more valuable than money.

Money is always available. Even if you're poor. Ways exist.

Time is passing, and one day we'll run out.

Sorry to be morbid.

In today's digital age, you need to optimize how you create content for your organization. Here are six content creation hacks.

1. Use templates

Use templates to streamline your work whether generating video, images, or documents.

Setup can take hours. Using a free resource like Canva, you can create templates for any type of material.

This will save you hours each month.

2. Make a content calendar

You post without a plan? A content calendar solves 50% of these problems.

You can prepare, organize, and plan your material ahead of time so you're not scrambling when you remember, "Shit, it's Mother's Day!"

3. Content Batching

Batching content means creating a lot in one session. This is helpful for video content that requires a lot of setup time.

Batching monthly content saves hours. Time is a valuable resource.

When working on one type of task, it's easy to get into a flow state. This saves time.

4. Write Caption

On social media, we generally choose the image first and then the caption. Writing captions first sometimes work better, though.

Writing the captions first can allow you more creative flexibility and be easier if you're not excellent with language.

Say you want to tell your followers something interesting.

Writing a caption first is easier than choosing an image and then writing a caption to match.

Not everything works. You may have already-created content that needs captioning. When you don't know what to share, think of a concept, write the description, and then produce a video or graphic.

Cats can be skinned in several ways..

5. Repurpose

Reuse content when possible. You don't always require new stuff. In fact, you’re pretty stupid if you do #SorryNotSorry.

Repurpose old content. All those blog entries, videos, and unfinished content on your desk or hard drive.

This blog post can be turned into a social media infographic. Canva's motion graphic function can animate it. I can record a YouTube video regarding this issue for a podcast. I can make a post on each point in this blog post and turn it into an eBook or paid course.

And it doesn’t stop there.

My point is, to think outside the box and really dig deep into ways you can leverage the content you’ve already created.

6. Schedule Them

If you're still manually posting content, get help. When you batch your content, schedule it ahead of time.

Some scheduling apps are free or cheap. No excuses.

Don't publish and ghost.

Scheduling saves time by preventing you from doing it manually. But if you never engage with your audience, the algorithm won't reward your material.

Be online and engage your audience.

Content Machine

Use these six content creation hacks. They help you succeed and save time.

Ashraful Islam

Ashraful Islam

3 years ago

Clean API Call With React Hooks

Photo by Juanjo Jaramillo on Unsplash

Calling APIs is the most common thing to do in any modern web application. When it comes to talking with an API then most of the time we need to do a lot of repetitive things like getting data from an API call, handling the success or error case, and so on.

When calling tens of hundreds of API calls we always have to do those tedious tasks. We can handle those things efficiently by putting a higher level of abstraction over those barebone API calls, whereas in some small applications, sometimes we don’t even care.

The problem comes when we start adding new features on top of the existing features without handling the API calls in an efficient and reusable manner. In that case for all of those API calls related repetitions, we end up with a lot of repetitive code across the whole application.

In React, we have different approaches for calling an API. Nowadays mostly we use React hooks. With React hooks, it’s possible to handle API calls in a very clean and consistent way throughout the application in spite of whatever the application size is. So let’s see how we can make a clean and reusable API calling layer using React hooks for a simple web application.

I’m using a code sandbox for this blog which you can get here.

import "./styles.css";
import React, { useEffect, useState } from "react";
import axios from "axios";

export default function App() {
  const [posts, setPosts] = useState(null);
  const [error, setError] = useState("");
  const [loading, setLoading] = useState(false);

  useEffect(() => {
    handlePosts();
  }, []);

  const handlePosts = async () => {
    setLoading(true);
    try {
      const result = await axios.get(
        "https://jsonplaceholder.typicode.com/posts"
      );
      setPosts(result.data);
    } catch (err) {
      setError(err.message || "Unexpected Error!");
    } finally {
      setLoading(false);
    }
  };

  return (
    <div className="App">
      <div>
        <h1>Posts</h1>
        {loading && <p>Posts are loading!</p>}
        {error && <p>{error}</p>}
        <ul>
          {posts?.map((post) => (
            <li key={post.id}>{post.title}</li>
          ))}
        </ul>
      </div>
    </div>
  );
}

I know the example above isn’t the best code but at least it’s working and it’s valid code. I will try to improve that later. For now, we can just focus on the bare minimum things for calling an API.

Here, you can try to get posts data from JsonPlaceholer. Those are the most common steps we follow for calling an API like requesting data, handling loading, success, and error cases.

If we try to call another API from the same component then how that would gonna look? Let’s see.

500: Internal Server Error

Now it’s going insane! For calling two simple APIs we’ve done a lot of duplication. On a top-level view, the component is doing nothing but just making two GET requests and handling the success and error cases. For each request, it’s maintaining three states which will periodically increase later if we’ve more calls.

Let’s refactor to make the code more reusable with fewer repetitions.

Step 1: Create a Hook for the Redundant API Request Codes

Most of the repetitions we have done so far are about requesting data, handing the async things, handling errors, success, and loading states. How about encapsulating those things inside a hook?

The only unique things we are doing inside handleComments and handlePosts are calling different endpoints. The rest of the things are pretty much the same. So we can create a hook that will handle the redundant works for us and from outside we’ll let it know which API to call.

500: Internal Server Error

Here, this request function is identical to what we were doing on the handlePosts and handleComments. The only difference is, it’s calling an async function apiFunc which we will provide as a parameter with this hook. This apiFunc is the only independent thing among any of the API calls we need.

With hooks in action, let’s change our old codes in App component, like this:

500: Internal Server Error

How about the current code? Isn’t it beautiful without any repetitions and duplicate API call handling things?

Let’s continue our journey from the current code. We can make App component more elegant. Now it knows a lot of details about the underlying library for the API call. It shouldn’t know that. So, here’s the next step…

Step 2: One Component Should Take Just One Responsibility

Our App component knows too much about the API calling mechanism. Its responsibility should just request the data. How the data will be requested under the hood, it shouldn’t care about that.

We will extract the API client-related codes from the App component. Also, we will group all the API request-related codes based on the API resource. Now, this is our API client:

import axios from "axios";

const apiClient = axios.create({
  // Later read this URL from an environment variable
  baseURL: "https://jsonplaceholder.typicode.com"
});

export default apiClient;

All API calls for comments resource will be in the following file:

import client from "./client";

const getComments = () => client.get("/comments");

export default {
  getComments
};

All API calls for posts resource are placed in the following file:

import client from "./client";

const getPosts = () => client.get("/posts");

export default {
  getPosts
};

Finally, the App component looks like the following:

import "./styles.css";
import React, { useEffect } from "react";
import commentsApi from "./api/comments";
import postsApi from "./api/posts";
import useApi from "./hooks/useApi";

export default function App() {
  const getPostsApi = useApi(postsApi.getPosts);
  const getCommentsApi = useApi(commentsApi.getComments);

  useEffect(() => {
    getPostsApi.request();
    getCommentsApi.request();
  }, []);

  return (
    <div className="App">
      {/* Post List */}
      <div>
        <h1>Posts</h1>
        {getPostsApi.loading && <p>Posts are loading!</p>}
        {getPostsApi.error && <p>{getPostsApi.error}</p>}
        <ul>
          {getPostsApi.data?.map((post) => (
            <li key={post.id}>{post.title}</li>
          ))}
        </ul>
      </div>
      {/* Comment List */}
      <div>
        <h1>Comments</h1>
        {getCommentsApi.loading && <p>Comments are loading!</p>}
        {getCommentsApi.error && <p>{getCommentsApi.error}</p>}
        <ul>
          {getCommentsApi.data?.map((comment) => (
            <li key={comment.id}>{comment.name}</li>
          ))}
        </ul>
      </div>
    </div>
  );
}

Now it doesn’t know anything about how the APIs get called. Tomorrow if we want to change the API calling library from axios to fetch or anything else, our App component code will not get affected. We can just change the codes form client.js This is the beauty of abstraction.

Apart from the abstraction of API calls, Appcomponent isn’t right the place to show the list of the posts and comments. It’s a high-level component. It shouldn’t handle such low-level data interpolation things.

So we should move this data display-related things to another low-level component. Here I placed those directly in the App component just for the demonstration purpose and not to distract with component composition-related things.

Final Thoughts

The React library gives the flexibility for using any kind of third-party library based on the application’s needs. As it doesn’t have any predefined architecture so different teams/developers adopted different approaches to developing applications with React. There’s nothing good or bad. We choose the development practice based on our needs/choices. One thing that is there beyond any choices is writing clean and maintainable codes.