Fetching data in web page through server script

Hi how you call an api from custom server script? I create a server script but when I call it inside script in web page is not working?
Here’s an example

and when I tried from my local http://localhost:8006/api/method/get_item the response were message: "oke"

when I tried to call it inside a script in web page through api call the message were

I need to get an item price for guest and display it in web that’s why I need a frappe call. Here’s what I’ve tried

method: “frappe.client.get_list”,
args: {
doctype: “Item”,
fields: [“item_code”, “item_name”, “description”]
callback: function (r) {
var data = r.message;



But frappe.client.get_list is not allowed for guest. Anyone can help?

You should write server script-like.

frappe.response["message"] = frappe.get_all("Item",filters={},fields=["name"])

After this, you should try this without login in postman if this will work then you should call this from in webpage using AJAX call.

	method: "GET",
	url: "http://server_url/api/method/get_items",
	dataType: "json",
	success: function(data) {