You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

wix-events-backend的createEvent()传入eventInfo参数报错如何解决

Wix Events createEvent 类型错误解决方案

错误原因

你传入的eventInfo对象属性名与WixEventInfo类型要求不匹配:你当前使用的location、scheduling属性是旧版命名,新版API要求对应属性名为locationInfo、schedulingInfo,这就是报错提示缺少这两个属性的原因。

修正后的完整代码

import { wixEvents } from "wix-events-backend";

const eventInfo = {
  title: "Healthy Living Series: Exercise and You",
  // 把原来的location改为locationInfo
  locationInfo: {
    name: "Community Hall",
    address: {
      formatted: "100 Gansevoort St, New York, NY 10014, USA",
      city: "New York City",
      subdivision: "New York",
      country: "USA",
      postalCode: "10014",
      streetAddress: {
        number: "100",
        name: "Gansevoort Street",
        apt: "10"
      }
    },
    type: 'VENUE',
  },
  // 把原来的scheduling改为schedulingInfo
  schedulingInfo: {
    startDate: "2021-09-14T13:30:00.000Z",
    endDate: "2021-09-14T15:30:00.000Z",
    timeZoneId: "America/New_York"
  },
  registration: {
    initialType: 'RSVP'
  }
};

const options = {
  language: "en"
};

export function myCreateEventFunction() {
  return wixEvents.createEvent(eventInfo, options)
    .then((result) => {
      return result;
    })
    .catch((error) => {
      console.error(error);
    });
}

额外注意事项

  • 该命名调整是Wix Events后端API的新版规范,旧版文档的示例未更新才会导致该问题
  • 确保项目依赖的wix-events-backend模块为最新版本,避免出现其他版本兼容问题
  • 运行测试时可打印返回的result对象,确认活动ID、状态等返回字段是否符合预期

内容的提问来源于stack exchange,提问作者Q A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 18:30:00