couchdb query a view with key parameters couchdb query a view with key parameters json json

couchdb query a view with key parameters


The key is a string hence you need to include " = %22, e.g http://127.0.0.1:5984/music/_design/albums/_view/by_release_date?key=%221993%22


I guess you are trying to query key range. Try to specify startkey and endkey:

http://127.0.0.1:5984/music/_design/albums/_view/by_release_date?startkey=1993&endkey=1993z

More details: http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options


Here is how i deal with it

let serverURL = "SERVER_IP:5984"let dd_name = 'email' // for examplelet viewname = "by_email" // for exampleconst findDocByEmail = email => {  let url = `${serverURL}/_design/${dd_name}/_view/${viewname}?key="${email}"`  fetch(url, {    method: 'GET',    mode: "no-cors",    headers:{      'Content-Type': 'application/json',      'Authorization': 'Basic ' + btoa('COUCH_USER:SECRET'), // you can remove this if not needed,    }  })  .then(res => {    return res.json()  })  .then(response => console.log('Response: ', response))  .catch(error =>  console.log(error))}