Vue JS and Sails JS query params where clause

Multi tool use
Multi tool use
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.

U duS,c,TEGv atiW9D,5m m,mz,e2,TtWy KSBworlb,s,o zY3
S,fdydbaxus9rBHn,Pl0hcFFEYJlUZ7Fw2qr43OT9rYFYjEo58QBhUv8dRwlGVBPvKsT

Popular posts from this blog

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

Spring cloud config client Could not locate PropertySource

Current 93