Uncaught (in promise) TypeError: _login__WEBPACK_IMPORTED_MODULE_1__.default.doUserLogin is not a function

Viewed 9

my login route api when i try to post i habe thie log (Uncaught (in promise) TypeError: login__WEBPACK_IMPORTED_MODULE_1_.default.doUserLogin is not a function) i tried everthings
i tried the const method with export defualt new but i have the same problem

import axios from "axios";

interface Credentials {
  username: string;
  password: string;
}

  async function doUserLogin(credentials:Credentials) {
    
    try {
      const response = await axios.post("http://localhost:8000/api/register", credentials);
      return response.data;
    } catch (error) {
      console.error("Error", error.response);
      return false;
    }
  }
 


export default   doUserLogin;

my login page


import React, { Component } from "react";

import './assets/login-style.css'

import doUserLogin  from"./login";




export  class Loginforme extends Component  {
  state = {
    username: "",
    password: "",
    
  }

  async handleFormSubmit(event) {
    event.preventDefault();
    const postData = {
      username: this.state.username,
      password: this.state.password,
    };
   
    const response = await doUserLogin   
    (postData);
   
 console.log('response',response) }




   render () {

    const { username, password} = this.state;

    return(
      

        <div className="login-page">
     
          <div className="login">
          <video loop autoPlay id="background-video">
            <source src={require('./assets/bg.mp4')}  type="video/mp4"></source>
          </video>
              <div className="background">
        <div className="shape"></div>
        <div className="shape"></div>
    </div>
    <form className="login-form" onSubmit={(event) => this.handleFormSubmit(event)}>
        <h3>Login Here</h3>

        <label >Username</label>
        <input type="text" name="name" value={username} onChange={(event)=> this.setState({username:event.target.value})}></input>

        <label >Password</label>
        <input type="text"name="password"  value={password}
                      onChange={(event) =>
                        this.setState({ password: event.target.value })}></input>

        <button  type="submit"  className="btn-login">Log In</button>
       
    </form>



                 
            </div>
        </div>
    )
   }

  };
export default Loginforme;

pls help me i tried evertyhing with a const adding export default new same problem

0 Answers
Related