Skip to main content

Posts

Showing posts with the label javascript

How to fetch data from a remote API in React.js

In this post, we will see how you fetching data from a remote s ource inside your React.js application. So let’s create a brand new React project with  Initialize a React project $ npx create - react - app todos $ cd todos $ npm start If you succeed in executing the above commands, you will see the default React page in the browser at  http :// localhost : 3000 . Now Let’s get into the fetching remote data task, for the sake of simplicity, in this article, we will use the native fetch API that comes with the browser. It uses JavaScript promises to resolve the asynchronous response.  Let’s create a brand new component called  Todo , for this create a file called  Todo.js  with following code in the  src  directory. import React , { Component } from 'react' ; class Todo extends Component {      render ( ) {       ...