Design-loving front-end engineer
Ryong
Design-loving front-end engineer
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
    • Framework
    • React
      • Concept
      • Library
      • Hook
      • Component
      • Test
    • NodeJS
    • Android
      • Concept
      • Code
      • Sunflower
      • Etc
    • Flutter
      • Concept
      • Package
    • Web
    • Web
    • CSS
    • Language
    • JavaScript
    • TypeScript
    • Kotlin
    • Dart
    • Algorithm
    • Data Structure
    • Programmers
    • Management
    • Git
    • Editor
    • VSCode
    • Knowledge
    • Voice
Design-loving front-end engineer

Ryong

React/Library

[ React ] axios

2022. 7. 30. 23:06

๐Ÿ”ด  Introduction

โšช  ๋ธŒ๋ผ์šฐ์ €, Node.js๋ฅผ ์œ„ํ•œ Promise API๋ฅผ ํ™œ์šฉํ•˜๋Š” HTTP ๋น„๋™๊ธฐ ํ†ต์‹  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

 

๐ŸŸ   Official

 

์‹œ์ž‘ํ•˜๊ธฐ | Axios Docs

์‹œ์ž‘ํ•˜๊ธฐ ๋ธŒ๋ผ์šฐ์ €์™€ node.js์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Promise ๊ธฐ๋ฐ˜ HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ Axios๋ž€? Axios๋Š” node.js์™€ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์œ„ํ•œ Promise ๊ธฐ๋ฐ˜ HTTP ํด๋ผ์ด์–ธํŠธ ์ž…๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์€ ๋™ํ˜• ์ž…๋‹ˆ๋‹ค(๋™์ผํ•œ ์ฝ”

axios-http.com

 

๐ŸŸก  Install

 
npm i axios

 

๐ŸŸข  Usage

 
import axios from "axios";

const BASE_URL = `https://api.coinpaprika.com/v1`;

export const fetchCoins = async () => {
  // ๐Ÿ’ก get์œผ๋กœ ๋ฐ›์•„์˜จ json ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”๋กœ jsonํ™” ์‹œ์ผœ์ค€๋‹ค.
  return await axios.get(`${BASE_URL}/coins`).then((response) => response.data);
};

 

์ €์ž‘์žํ‘œ์‹œ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'React > Library' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[ React ] react-helmet  (0) 2022.07.30
[ React ] recoil  (0) 2022.07.30
[ React ] apexchart  (0) 2022.07.30
[ React ] @tanstack/react-query  (0) 2022.07.30
[ React ] styled-components  (0) 2022.07.18
    'React/Library' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • [ React ] recoil
    • [ React ] apexchart
    • [ React ] @tanstack/react-query
    • [ React ] styled-components
    Design-loving front-end engineer
    Design-loving front-end engineer
    ๋””์ž์ธ์— ๊ด€์‹ฌ์ด ๋งŽ์€ ๋ชจ๋ฐ”์ผ ์•ฑ ์—”์ง€๋‹ˆ์–ด Ryong์ž…๋‹ˆ๋‹ค.

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”