🔍 What do you find here?


Axios

Axios is a promise-based HTTP Client for node.js and the browser. It is isomorphic (= it can run in the browser and nodejs with the same codebase). On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests. Official website: https://axios-http.com/docs/intro

// set up the baseURL

import axios from 'axios';

export const api = axios.create({
  baseURL: '<http://localhost:3000/api>',
});

// using it
import { api } from '../../services/api';

const { data } = await api.get('users');

Bun

Develop, test, run, and bundle JavaScript & TypeScript projects—all with Bun. Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager. Official website: https://bun.sh/

❯ curl -fsSL <https://bun.sh/install> | bash

Mirage JS

Mirage JS isAxios is a promise-based HTTP Client for node.js and the browser. It is isomorphic (= it can run in the browser and nodejs with the same codebase). On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests.an API mocking library that lets you build, test and share a complete working JavaScript application without having to rely on any backend services. Official website: https://miragejs.com/

import { createServer, Model } from 'miragejs';

type User = {
  name: string;
  email: string;
  created_at: string;
};

export function makeServer(): any {
  const server = createServer({
    models: { // database table
      user: Model.extend<Partial<User>>({}),
    },

    routes() {
      this.namespace = 'api'; // base url
			this.timing = 750; // delay to respond

      this.get('/users'); // shorthand CRUD
      this.post('/users');

			this.namespace = '';
      this.passthrough(); // force all routes to pass through Mirage
    },
  });

  return server;
}