【问题标题】:Export page content using http functions使用http函数导出页面内容
【发布时间】:2020-10-21 15:29:24
【问题描述】:

我试图按照此处找到的示例进行操作:

https://support.wix.com/en/article/corvid-exposing-a-site-api-with-http-functions

使用 HTTP get 在我的网站上公开某些内容,但我不明白如何定义他们的示例页面上看到的函数。

他们有:get_apartmentlistings(),但apartmentlistings 在哪里,我该如何定义类似的东西?

这是我的页面:https://cesarcaiooliveira.wixsite.com/cesar/page

我正在尝试阅读 text 内容,这就是我已经做过的:

import { ok, notFound, serverError } from 'wix-http-functions';
import wixData from 'wix-data';

export function get_textlist() {
  let options = {
    "headers": {
      "Content-Type": "application/json"
    }
  };
  return wixData.query("textlist")
  .find()
  .then(results => {
    if (results.items.length > 0) {
      options.body ={
        "items": results.items
      }
      return ok(options);
    }
  })

}

export function get_textlist()

我的疑问在这里 ^ 我如何将它链接到我的文本内容?

【问题讨论】:

    标签: php velo


    【解决方案1】:

    HTTP 函数是后端代码。他们不能直接访问页面上的元素。这是有道理的,因为当 API 的使用者调用 HTTP 函数时,使用者不在您网站的页面上。

    在这里很难准确说出您想做什么,但也许您最好将要公开的信息存储在数据库集合中而不是页面上。您可以在 HTTP 函数中查询数据库集合以返回数据。

    【讨论】:

      猜你喜欢
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-01
      相关资源
      最近更新 更多