Login with JavaScript

Options

I'm trying to login to xano from a web application with javascript.

Code:
function login(){
    event.preventDefault()
    var url = 'xxxxxxxxxxxxxxxxxxxxxx/login'
    email =  document.getElementById("email").value;   
    password = document.getElementById("password").value;

    obejct = {
        "email": email,
        "password": password
    }    
   
    makePost(url,object);    
}

function makePost(url, object){
    let request = new XMLHttpRequest();
    request.open ("POST", url, true);  
    request.setRequestHeader("Content-Type","applictaion/json");
    request.send(object);
    request.onload = function(){
        console.log(this.responseText);
    }
    return request.responseText
}
But I'm getting the following responseBut I'm getting the following response::But I'm getting the following response:{"code":"ERROR_CODE_INPUT_ERROR","message":"Missing param: field_value","payload":{"param":"field_value"}}

What is wrong?

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I've seen this before. In that case, in the Xano function stack the client had a query for managing authentication. And in that query it is asking for a "field_value" that was supposed to be a variable, but instead is probably now a string. Fixing the reference in the stack cleaned up the problem. I did this online with the client as part of a mentoring session, which you can sign up for on my site. The form emails you a scheduling link that can get you sorted same day/next day. 

    But take a look for yourself first - sometimes a fresh pass reveals the problem without outside help! As one approach, find where you have the "field_value" reference, and make sure it points to a variable or an input, and not a fixed text value.