Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react password check wordpress api

validate() {
  let username = this.state.username;
  let password = this.state.password;
  let userPassCombination = username + ':' + password;
  let encodedPass = base64.encode(userPassCombination);

  let headers = {
    'Content-Type': 'text/json',
    Authorization: 'Basic ' + encodedPass,
  };

  fetch(myConstants.URL + '/wp-json/', {
    method: 'GET',
    headers: headers,
  }).then(responseData => {
    //console.log(JSON.stringify(responseData));
    if (responseData.ok) {
      this.props.navigation.navigate('Profile', {
        username: this.state.username,
      });
    } 
    else {
      alert('wrong information.');
    }
  });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #password #check #wordpress #api
ADD COMMENT
Topic
Name
1+9 =