- I'm sending GET request on changing Text.
- So if I recommend 'my_username' at the initial point and user changes to 'hi_user', I'm sending about 18 GET requests.
The request is like this below
url: ${ROOT_URL}/profile/unamecheck/?un=${username}
body: username
response: {valid: true}
Here is my React Code
_handleChange = async (username) => {
this.setState({username})
let response = await axios.get(`${ROOT_URL}/profile/unamecheck/?un=${username}`)
if (response.status === 200) {
if(response.data.obtained) {
this.setState({isValidUsername: false})
} else {
this.setState({isValidUsername: true})
}
} else {
}
console.log('isValidUsername');
console.log(this.state.isValidUsername);
}