Posts

Showing posts with the label HTTP get request

API Get Request (class-based method)

Image
 There are two methods in react js to work on this: class-based and functional components. HTTP get request using the class-based method: import React, { Component } from "react" ; First, we need to import the above dependencies, which will be used to create a class-based function. There is a shortcut, rce and then press enter key to get the basic structure of the function as follows. export class Api extends Component {   render () {     return (       < div >Api</ div >     )   } } export default Api The only method must be  defined in a  React.Component  subclass is called    render()   . constructor (props) {   super (props)   this .state = {      first: ""   } } Use rconst snippet for constructors. The constructor is a method: That’s automatically called during the creation of an object from a class. It can handle your initial setup stuff like default...