---
title: "Discussion on \"Create A custom Http Service Provider in React\" | Hashnode"
description: "Discussion on \"Create A custom Http Service Provider in React\". Hey there! This post is for my front-end app while building  Codemarka  and a good practice I adopted and you should too.\nTHE PROBLEM:\nOn my server, I've got routes that are protected. To access them you'll need to provide an auth token in the reques..."
url: "https://hashnode.com/posts/create-a-custom-http-service-provider-in-react/5fd3280dcd0355570faea63a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Create A custom Http Service Provider in React](https://blog.codemon.me/create-a-custom-http-service-provider-in-react?utm_source=hashnode&utm_medium=feed)

Hey there! This post is for my front-end app while building Codemarka and a good practice I adopted and you should too. THE PROBLEM: On my server, I've got routes that are protected. To access them you'll need to provide an auth token in the reques...

Dec 11, 2020 · 4 min read · blog.codemon.me  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#reacthooks](https://hashnode.com/tag/reacthooks)

## Written by

[Johnson awah Alfred](https://hashnode.com/@codemon)

@codemon

  
[View profile](https://hashnode.com/@codemon)

Backend engineer and Cloud security and computer networking enthusiast

Alfred is a software engineer and cyber security specialist based in Enugu, Nigeria. He is passionate about solving real-world problems through well-crafted software and leveraging blockchain technology.

## Responses 2

Markdown supported · ⌘↵ to post

[Rahul Singh](https://hashnode.com/@rahuladream)

[Dec 11, 2020](https://hashnode.com/posts/create-a-custom-http-service-provider-in-react/5fd3280dcd0355570faea63a/comment/5fd3994f95130967e0991cec)

Love this ❤️ I would love to hear your thoughts on [4 Programming Language That Will Dominate 2021](https://blog.voltry.in/4-programming-language-that-will-dominate-2021-1)

[Osinachi Chukwujama](https://hashnode.com/@Vicradon)

[Dec 11, 2020](https://hashnode.com/posts/create-a-custom-http-service-provider-in-react/5fd3280dcd0355570faea63a/comment/5fd33d27cd0355570faea731)

Quite a neat method. Axios has a way of setting the authorization token once, globally. By using

```
axios.defaults.headers.common['Content-Type'] = 'application/json';
axios.defaults.headers.common['Authorization'] = `Bearer ${access_token}`;
```

Check this [StackOverflow answer](https://stackoverflow.com/a/52115487/10939384) for more info.

[Johnson awah Alfred](https://hashnode.com/@codemon)

[Dec 11, 2020](https://hashnode.com/posts/create-a-custom-http-service-provider-in-react/5fd3280dcd0355570faea63a/comment/5fd33d27cd0355570faea731#reply-5fd34e4402d534634d37f84c)

Yeah.. this works just fine as a clean alternative to the object thing I did above.
