Vue JS and Sails JS query params where clause

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Vue JS and Sails JS query params where clause



i'm using Vue Resource to send http requests to my Sails JS backend



everything is working fine, the only problem is the 'where' clause



by sails isn't implementing the way it should



here is my code



my template


<div class="content">
<input type="text" class="search" placeholder="Search Users" v-model="search">
<button v-on:click="searchUsers" class="add-btn search-btn"> <i class="fas fa-search"></i> </button>
<div class="list">
<ul class="lists-group">
<template v-for="(user, index) in users">
<router-link v-bind:to="'users/user/' + user.id" class="lists-item">{{ user.firstName }} {{ user.lastName }}</router-link>
</template>
</ul>
</div>
</div>



my script


export default {
data: function() {
return {
search : '',
users: ,
}
},
methods: {
searchUsers: function() {
this.$http.get('http://localhost:1337/users?firstName=' + this.search).then(result => {
this.users = result.body;
})
if (!this.search) this.getAllUsers();
},
getAllUsers: function() {
this.$http.get('http://localhost:1337/api/v1/users').then(users => {
this.users = users.body.users;
})
}
},
created: function() {
this.$http.get('http://localhost:1337/api/v1/users').then(users => {
this.users = users.body.users;
})
}
}



i tried to do a get request using { params : { where : { firstName : contains : this.search } } }


{ params : { where : { firstName : contains : this.search } } }



but still not working



what is the best approach to send a query like this


'http://localhost:1337/users?where={"firstName":{"contains":"UserName"}, "occupation": "doctor"}'









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived