Wanted to write http function with GET function as per https://www.wix.com/corvid/reference/wix-http-functions.html#get
Database values is noted as below:
Code is written as below:
'use strict';
import wixData from 'wix-data';
import wixHttpFunctions from 'wix-http-functions';
import {ok, response, notFound, serverError} from 'wix-http-functions';
export function get_fetchrecords(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
// query a collection to find matching items
return wixData.query("SampleCollection")
.eq("title", request.path[0])
.find()
.then( (results) => {
// matching items were found
if(results.items.length > 0) {
options.body = {
"items": results.items
};
return ok(options);
}
// no matching items found
options.body = {
"error": `'${request.path[0]}' was not found`
};
return notFound(options);
} )
// something went wrong
.catch( (error) => {
options.body = {
"error": error
};
return serverError(options);
} );
}
I am trying to using GET function in external app to pull the data from row with title value as “3” by using https://wixtozapier.com/_functions/fetchrecords?&title=3
Instead of getting only the row with title value 3, I get all the records from the database.
How can I rectify this to get only the required row?