Skip to main content

React Post Request

import React from "react";

// class Car {
//     constructor(name) {
//         this.brand = name;
//     }
//     Present() {
//         return 'I have a ' + this.brand +' Car In My Home';
//     }
// }

// class Model extends Car
// {
//     constructor(name,mod){
//         super(name);
//         this.model=mod;
//     }

//     show(){
//         return this.Present() + ',it is a ' +this.model
//     }

// }

// class Header{
//     constructor(){
//         this.color="Red";

//     }
//     ChangeColor=function() {
//         document.getElementById("demo").innerHTML +=this;
//     }
class Header extends React.Component {
    
    constructor(props)
    {
        super(props);
        this.state={
         response:[]
        }
    }

    //   postData(url = '', data = {}) {
    //     // Default options are marked with *
    //     const response =  fetch(url, {
    //       method: 'POST', // *GET, POST, PUT, DELETE, etc.
    //       mode: 'cors', // no-cors, *cors, same-origin
    //       cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
    //       credentials: 'same-origin', // include, *same-origin, omit
    //       headers: {
    //         'Content-Type': 'application/json'
    //         // 'Content-Type': 'application/x-www-form-urlencoded',
    //       },
    //       redirect: 'follow', // manual, *follow, error
    //       referrerPolicy: 'no-referrer', // no-referrer, *client
    //       body: JSON.stringify(data) // body data type must match "Content-Type" header
    //     });
    //     return  response.json(); // parses JSON response into native JavaScript objects
    //   }

    componentDidMount(){
        fetch("http://is-S2130:5000/api/MoveJobtoWms/UpdatingActivityDetail",{
            method:'POST',
            mode:'cors',
            cache:'no-cache',
            credentials:'same-origin',
            headers:{
               'Content-Type':'application/json'
            },
            redirect:'follow',
            referrerPolicy:'no-referrer',
            body:JSON.stringify({id:1})
        })
        .then(res=>res.json())
        .then(
            (result)=>{
                this.setState({
                   response:result
                });
            },
            (error)=>{
            this.setState({
                response:error
            });
        }
       
        )
    }

  render() {
    
    return (
      <div>
        <h1>Enter the ID</h1>
        <input type="text" id="id" placeholder="Enter ID"></input>
        <input type="button" id="btnsubmit" value="Submit" ></input>
        <div>{this.state.response.is_success}</div>
        <div>{this.state.response.data}</div>
        <div>{this.state.response.message}</div>
      </div>
    );
  }
}
export default Header;

Comments

Popular posts from this blog

Vb Net reference for JSon Extraction of String to Json .

 Public Shared Function SupplementaryUpload(ByVal ICMSIntegrationID As String, ByVal CMSActivityID As String, ByVal File As String, ByVal Flag As String, ByRef ErrorResponse As String) As Boolean         Try             'Dim client As New RestSharp.RestClient()             ' Dim BMJ_LinkUpload As String = ConfigurationManager.AppSettings("BMJ_API_Upload")             Dim BMJ_LinkUpload As String = "http://is-s2130:5000/BMJIntegration/SupplementaryUpload"             'client.BaseUrl = New Uri(BMJ_LinkUpload & "?ICMSIntegrationID=" & ICMSIntegrationID & "& CMSActivityID=" & CMSActivityID & "&File=" & File & "&Flag=" & Flag)             '''?ICMSIntegrationID=56445096&CMSActivityID=29&File=D:\admin.JPG&Flag=article_resource")         ...

Hosting multiple Environments

using   System ; using   System . Collections . Generic ; using   System . Linq ; using   System . Threading . Tasks ; using   Microsoft . AspNetCore . Builder ; using   Microsoft . AspNetCore . Hosting ; using   Microsoft . AspNetCore . HttpsPolicy ; using   Microsoft . AspNetCore . Mvc ; using   Microsoft . Extensions . Configuration ; using   Microsoft . Extensions . DependencyInjection ; using   Microsoft . Extensions . Hosting ; using   Microsoft . Extensions . Logging ; using   Microsoft . EntityFrameworkCore ; using   MovejobtoWms . Models ; using   Microsoft . AspNetCore . Authentication . Cookies ; using   Microsoft . AspNetCore . Authentication ; using   Newtonsoft . Json ; using   Microsoft . AspNetCore . Http ; using   System . Net . Http . Headers ; namespace   MovejobtoWms {      public   class   Star...

Code Example Zip File Extraction and Download in dotnet core api

using   System . Security . Principal ; using   Microsoft . Win32 . SafeHandles ; using   System . Dynamic ; using   System . Reflection . Metadata . Ecma335 ; using   System . Reflection . Metadata ; using   System . Text ; using   System . Runtime . CompilerServices ; using   System . Net . Http ; using   System ; using   System . Collections . Generic ; using   System . Linq ; using   System . Net . Mime ; using   System . Threading . Tasks ; using   Microsoft . AspNetCore . Http ; using   Microsoft . AspNetCore . Mvc ; using   Microsoft . EntityFrameworkCore ; using   MovejobtoWms . Models ; using   System . IO ; using   System . Net ; using   Microsoft . AspNetCore . Authorization ; using   System . IO . Compression ; using   System . Net . Http . Headers ; using   System . Net . Http . Formatting ; using   System ...