coreui / coreui-free-react-admin-template

Open source admin template based on Bootstrap 5 and React.js
https://coreui.io/product/free-react-admin-template/
MIT License
4.6k stars 2.33k forks source link

fetch request is not working below is my code #323

Closed techpawan closed 2 years ago

techpawan commented 3 years ago

import React from 'react' import ReactDom from 'react-dom'; import { DocsLink } from 'src/reusable' import { CButton, CCard, CCardBody, CCardFooter, CCol, CContainer, CForm, CInput, CInputGroup, CInputGroupPrepend, CInputGroupText, CRow, CCardHeader, CProgress, CProgressBar } from '@coreui/react' import CIcon from '@coreui/icons-react'

class Register extends React.Component { constructor(props) { super(props); this.t this.onRegisterUser = this.onRegisterUser.bind(this); this.state = { showMe: false, message: '' }; } changeHandler = e => { this.setState({ [e.target.name]: e.target.value }) } //on click function onRegisterUser = () => { this.setState({ showMe: true })

const {parse, stringify} = require('flatted/cjs');
let appUser = {
  PassWord:'ddd',//this.state.bind(password),
  EmailId: 'ddd',//this.state.bind(email),
  UserName: 'ddd',//this.state.bind(username),
  MobileNumber: 'ddd',//this.state.bind(mobilenumber)
};
fetch('https://localhost:44380/api/AppUsers', { mode: 'no-cors' }, {
  method: 'POST',
  headers: { 'Content-type': 'application/json', 'Access-Control-Allow-Headers': '*' },
  body: appUser//{ PassWord: this.password, EmailId: this.email, UserName: this.username, MobileNumber: this.mobilenumber }
})
  .then(response => response.json())
  .then(data => this.setState({ message: 'Registred Successfully' }));
// .then(res => {
//   if (res.JSON()) {
//     let data = res;
//     this.setState({ message: 'Registred Successfully' });
//   }
// });

}

render() { const {username,email, mobilenumber, password, repeatpassword } = this.state return (

Register

Create your account

{ this.state.showMe ?

Registration In Progress!!

: null } @ +91 Register!!
facebook twitter
)

} }

const element = ReactDom.render(element, document.getElementById('root')); export default Register

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions