user1659653
user1659653

Reputation: 334

Flask restless operators not filtering properly

I'm developing a login for a mobile web app using Flask and Flask restless. For the moment I have only 1 record in my database for testing, when I send my AJAX request to Flask restless, it seems to return me this record all the time. Here's an example:

    var username = $('#txt-username').val(),
        password = $('#txt-pass').val(),
        queryFields = [{'name': 'Username', 'op': 'eq', 'value': username},{'name': 'Password', 'op': 'eq', 'value': password},{'single': true}];


    $.ajax({
        type: 'GET',
        url: url,
        data: {'q' : JSON.stringify({'fields': queryFields})},
        contentType: 'application/json'
    }).done(function(){
        localStorage.setItem('username',username);
        fn;
    });

so this is a simple AJAX request that tries to filter a user by sending it's username and password to the backend. It doesn't matter if I input a non existent username or password, the backend always returns the same response which is my database's only record which means it isn't filtering the data according to the request I send.

Any thoughts on this?

Upvotes: 0

Views: 359

Answers (2)

AdriVelaz
AdriVelaz

Reputation: 563

This may be old, but you didn't accept an answer.

Shouldn't value be changed to val in the filter.

Upvotes: 0

rcomblen
rcomblen

Reputation: 4649

data: {'q' : JSON.stringify({'fields': queryFields})},

should read

data: {'q' : JSON.stringify({'filters': queryFields})},

Upvotes: 1

Related Questions