How to setup

  1. Change the base url:

axios.defaults.baseURL = "http://localhost:4000";

axios.defaults.baseURL = "https://jsonplaceholder.typicode.com";

  1. In terminal(in vs-code) enter npm start or yarn start
  2. In another terminal enter json-server --watch data/db.json --port 3006 for run local database.(if port 3006 is bussy, change it)

If want to use the default base URL for a specific component using the below function

import axios from "axios";

const instance = axios.create({
  baseURL: "http://localhost:4000",
});

instance.defaults.headers.common["Authorization"] = "AUTH_TUKEN";

export default instance;