skip to Main Content

I’m new to develop app using jquery, react, bootstrap
below my code :

button() {
    var api = "https://localhost/api/api.php/users_login?filter=username,eq,admin";
    var settings = {
      async: true,
      crossDomain: true,
      url: api,
      method: "GET",
    }
    jquery.ajax(settings).done(function (response) {
      var array = jquery.map(response, function (value,index) {
        return value;
      });
    });
}

and the output json from api from localhost

{"users_login":{"columns":["id","username","password"],"records":[[2,"admin","admin"]]}}

I find it difficult to get value of username and password.
I’m already trying to search on google about my problem and use any advice which I found, but still can’t find the best answer. what i want is

var uname = value of username...;
var pass = value of password...;

and I need advice

  • whether it is good to build front-end web using react+bootstrap for
    develop cms blogging ? (back-end using laravel)
  • what the best source as dependency for dynamic url pagination like wordpress so can SEO friendly ?

please help me to resolve the problem and give me advice.
thank you very much.

2

Answers


  1. Chosen as BEST ANSWER

    this the answer which I'm applied refer from mayank shukla

        jquery.ajax(settings).done( (response) => {
          let items = response;
          items.users_login.records.forEach( (el) => {
            var datacompare = el[1];
            var passcompare = el[2];
          });
          // continue my coding
        });
    

    thank you very much.


  2. JSON that you pasted contains the username and password in users_login key, and records is itself an array, so you need to use it like this:

    let a = {"users_login":{"columns":["id","username","password"],"records":[[2,"admin","admin"]]}};
    
    a.users_login.records.forEach((el)=>{el.length > 2 ?console.log(el[1], el[2]) : ''})
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search