javascript - wix-events-backend createEvent() 代码在 eventInfo 上失败
问题描述
尝试为 Wix 事件创建程序化事件。
遵循此处详述的步骤: https ://www.wix.com/velo/reference/wix-events-backend/wixevents/createevent
IE,
import { wixEvents } from "wix-events-backend";
const eventInfo = {
title: "Healthy Living Series: Exercise and You",
location: {
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: {
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);
});
}
提供的代码片段在 eventInfo 参数上失败并出现此错误:
Argument of type '{ title: any; description: any; about: any; location: { name: any; address: { formatted: any; city: any; subdivision: any; country: any; postalCode: any; streetAddress: { number: string; name: string; apt: string; }; }; type: string; }; scheduling: { ...; }; registration: { ...; }; }' is not assignable to parameter of type 'WixEventInfo'. Type '{ title: any; description: any; about: any; location: { name: any; address: { formatted: any; city: any; subdivision: any; country: any; postalCode: any; streetAddress: { number: string; name: string; apt: string; }; }; type: string; }; scheduling: { ...; }; registration: { ...; }; }' is missing the following properties from type 'WixEventInfo': locationInfo, schedulingInfo
任何人都有任何线索如何克服这个问题?
解决方案
我在编辑器中看到了同样的错误,但如果你实际运行代码,你可能会得到不同的错误,通过 .catch((error) 传递到 console.log。
我能够通过 a) 更改不正确的位置国家/地区字段来使用测试代码创建事件
country: "USA",
到
country: "US",
b) 删除调度字段的开始和结束日期并改用 TBD:
scheduling: {
tbd: true,
tbdMessage: "pending my dates",
timeZoneId: "EST"
}
我尝试了许多不同的开始日期和结束日期格式,但无法让它们中的任何一个工作,包括示例中的那些
startDate: "2021-09-14T13:30:00.000Z",
endDate: "2021-09-14T15:30:00.000Z",
Wix 文档也没有多大帮助,例如在定义输入参数 eventInfo 时 - 它说结构包含名称为“schedulingInfo”的对象,但这是不正确的,它必须是“调度”;奇怪的是,如果您在代码中将其更改为 scheduleInfo(以及将位置更改为 locationInfo),您不会收到您发布的静态错误,但您确实会收到运行时错误。
我将在 Wix 的论坛中提出这个问题,所以要小心。
推荐阅读
- javascript - 未捕获的类型错误:无法在 app.js:5 处设置 null 的属性“onclick”
- python - Scrapy :- 分页抓取工作正常,但无法从下一页开始抓取内容
- c++ - 如何处理类中的字符串输入..?
- flutter - 我在 josn.decode(resp) 上遇到错误(错误:需要一个“字符串”类型的值,但得到一个“列表”类型的值
' 什么时候 ) - html - 如何在左侧逐行设置所有复选框及其标签?
- python - 将新创建的列添加在一起
- java - 点亮(空).cast(“地图
") 不被接受。如何转换为具有价值对象的地图? - php - 无法将 Angular 中的数据插入到 Laravel API
- javascript - 按钮单击需要在移动设备上双击或长按
- reactjs - React Router Dom-在 React 中处理 404 路由(嵌套路由器)