axios
npm i axios
axios
import axios from "axios";

async function getData() {
	const resGet = await axios.get("http://localhost:8000/datas");
	const resData = resGet.data;
	console.log('data :>> ', resData);
	return resData
};
axios
Using npm:

$ npm install axios


Using bower:

$ bower install axios


Using yarn:

$ yarn add axios


Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>


Using unpkg CDN:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
axios
const fetch = async () => {
    const response = await axios
      .get("https://fakestoreapi.com/products")
      .catch((err) => {
        console.log("api error", err);
      });
    console.log(response);
  };
axios
// npm install axios
const axios = require('axios');

// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
  });

// Optionally the request above could also be done as
axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  })
  .then(function () {
    // always executed
  });  

// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
  try {
    const response = await axios.get('/user?ID=12345');
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}
axios
axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
  
 #Performing multiple concurrent requests
  function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

Promise.all([getUserAccount(), getUserPermissions()])
  .then(function (results) {
    const acct = results[0];
    const perm = results[1];
  });
axios
//npm install axios

const axios = require('axios').default;
async function getUser() {
  try {
    const response = await axios.get('/user?ID=12345');
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}
axios
import axios from "axios";

export default axios.create({
  baseURL: "http://localhost:8080",
  headers: {
    "Content-type": "application/json"
  }
});
axios
function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

Promise.all([getUserAccount(), getUserPermissions()])
  .then(function (results) {
    const acct = results[0];
    const perm = results[1];
  });
Source: www.npmjs.com
axios
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
  });

// Optionally the request above could also be done as
axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  })
  .then(function () {
    // always executed
  });  

// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
  try {
    const response = await axios.get('/user?ID=12345');
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

Shell/Bash相关代码片段

how to remove quotes from a string in bash

how to install grafana-prometheus kubernetes

show laptop battery health windows 10

ubuntu terminal won't open

uninstall pip ubuntu

fatal: detected dubious ownership in repository

docker npm network timeout

install nvidia drivers pop os

how to list apt holds

how to install yo code generator

install notion ubuntu

zsh-autocomplete

install yabai macos

cwpanel install rocky linux 9

tar command not found

Correct use of command substitution in Bash

how to push changes to github from terminal

ollama uninstall

rocky 9 mysql

nodejs jest only on specific file

windows ubuntu wsl

ignore a folder in SVN

npm install for express the version 5

add local .env to vercel env

pihole unbound install and config

Create SSH Key

kitty terminal install

X server (windows, macos and linux) for docker gui

rename a local Git branch

delete a Git branch locally and remotely

laravel generate sitemap xml

max github file size

find-large-files-linux

git pull accept all incoming changes

upgrade to fedora 40 from terminal

upgrade all packages pnpm

imperative configmap command

how to show ip address in linux

linux libreoffice cli convert docx to txt

how to install .run file in ubuntu

start tensorboard

how to install xampp in ubuntu

matlab install toolbox

how to open matlab after installation

matlab installation key

rebasing git

how to check if apache is installed

install dual boot ubuntu windows 10

yay install pip

Hold linux kernel packages

Install apache utils

Install necessary software properties

Configure automatic restart

list pods all namespaces

Change remote origin url

echo path replace : with linebreak

git unstage all

install miniconda

docker keeps creating new containers

set git credentials with access token

docker ststus

instalar insomnia linux

install jenkins docker

install docker debian 5

AddDbContext

AddNewtonsoftJson

zip except folder

install openmpi ubuntu

remove anydesk from startup linux

stabalize a linux shell with one python command

move images without registry

composer drupal installation

remove bash history forever

docker compose pull latest image

windows create shortcut that rins cmd

ubuntu cannot play mp4 video

install jupyter kernel

wsl networking becomes slow windows 10

dynamic python aliases on mac

git remove file from gitirgnore