Git Product home page Git Product logo

fetch-data-from-api's Introduction

How to fetch Data from a restful api?

Hi! Im Whirl and im gonna teach you how to fetch data from a restful api

What is a API?

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you're using an API.

How to make your own api?

This is not the topic of this tutorial but still you can view it here!

make sure to join that server to view

How to fetch data

1 - you need to be familiar with json (it is really easy )

2 - for this tutorial i'll use this api - https://brawlapi.com

3 - now go the brawlers page in endpoints category

4 - they have listed a endpoint there

5 - when you click on that link you see some text

6 - Now We would fetch that data and represent it on your console

7 - write this code -

 const fetch = require('node-fetch')//npm i node-fetch
fetch('https://api.brawlapi.com/v1/brawlers/16000038')
    .then(res => res.json())
    .then(json => console.log(json));

This would print what was on that endpoint page!

Now if you look closely they mention a brawler name , id , is released and much more !

How to get this content?

i'll use this method - console.log(json.name) - this would log the brawler name which in this case is surge

There may be some api's which have a more complicated json for which traditional javascript method of reading objects can be used!

Thanx To -

Whirl

fetch-data-from-api's People

Contributors

whirlxd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.