OK, found an good example from Yisrael here…
also tried it out. It worked inside the example when i was requesting for example like… https://mt2-king.wixsite.com/mysite/_functions/recipe ,
but when i am doing the same thing on my own example, it doesn’t work at all.
I have right now copy and paste one of the given functions in the given example and modified it a little bit to my own needs.
import {ok, created, badRequest, notFound, serverError} from 'wix-http-functions';
export function get_xxx(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
let query = wixData.query("Team");
if (request.query) {
var query_keys = Object.keys(request.query);
query_keys.forEach(function (entry) {
query = query.contains(entry, request.query[entry]);
});
}
return query
.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]} ${request.path[1]}' was not found`
};
return notFound(options);
})
// something went wrong
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
});
}
- Collection-Name = “Team”
- Code is written down in the Back-End-Section (JSW-File)
- Function called —> “xxx” (get_xxx)
Why it is not working when i try to call this http-function with…
https://www.media-junkie. com/http-test/_functions/xxx
???