情境 - 循环事件数组并从JSON解析中分配属性
预期结果 - 上传到Parse云存储
我正在使用的API -
https://www.eventbrite.com/developer/v3/formats/event/#ebapi-std:format-event https://www.parse.com/docs/js/guide
我是Javascript的新手(实际上可能存在多个语法错误)
在尝试部署到解析云代码时,我不知道为什么我会在第83行获得此error
我传递的内容 -
function loopEvents(events) {
if (j == cities.length) {j=0};
for (var i = 0; i < events.length; i++) {
//Parse.Cloud.useMasterKey(); is not needed ATM I think
console.log("assigning properties for " + cities[j] + ".");
list.save({ // saving properties
number: String(i); // ****THIS IS THE LINE 83****
uri: events[i]["resource_uri"];
url: events[i]["url"];
id: events[i]["id"];
name: events[i]["name"]["text"];
description: events[i]["description"]["text"] || "None provided.";
status: events[i]["status"];
capacity: String(events[i]["capacity"]);
logo: events[i]["logo_id"]["logo"] || "http://www.ecolabelindex.com/files/ecolabel-logos-sized/no-logo-provided.png";
start: moment(events[i]["start"]["utc"]);
end: moment(events[i]["end"]["utc"]);
online: events[i]["online_event"];
currency: events[i]["currency"];
ticketClasses: events[i]["ticket_classes"] || "It's freeee!";
ticketClassesNames: events[i]["ticket_classes"]["name"] || "None provided.";
ticketClassesCost: events[i]["ticket_classes"]["cost"] || "It's freeee!";
ticketClassesDescription: events[i]["ticket_classes"]["description"] || "None provided.";
}, {
success: function(list) {
console.log("RIP CloudCode, we had good times!");
},
error: function(list, error) {
console.log("u fuc*ed up, with error: " + error.text + ", son.");
}
});
}
j++;
}
整个功能作为截图(语法高亮显示可读性) - &gt; code
作为文本的功能 - &gt;
$('#countdown').text(3).fadeIn(4000).delay(500).fadeOut(4000)
.text(2).fadeIn(4000).delay(5000).fadeOut(4000)
.text(1).fadeIn(4000).delay(5000).fadeOut(4000);
也许它完全错了,感谢努力和建设性的答案;)))如果你需要任何其他信息,只需发表评论,我就会编辑。
答案 0 :(得分:1)
当您使用object
时,分号;
的语法无效。
从对象内的所有行中删除;
。
number: String(i);
// ^
改为使用,
逗号。
number: String(i),
// ^
<强>代码强>
// Notice the comma at the end of each element
list.save({ // saving properties
number: String(i),
uri: events[i]["resource_uri"],
url: events[i]["url"],
id: events[i]["id"],
name: events[i]["name"]["text"],
description: events[i]["description"]["text"] || "None provided.",
status: events[i]["status"],
capacity: String(events[i]["capacity"]),
logo: events[i]["logo_id"]["logo"] || "http://www.ecolabelindex.com/files/ecolabel-logos-sized/no-logo-provided.png",
start: moment(events[i]["start"]["utc"]),
end: moment(events[i]["end"]["utc"]),
online: events[i]["online_event"],
currency: events[i]["currency"],
ticketClasses: events[i]["ticket_classes"] || "It's freeee!",
ticketClassesNames: events[i]["ticket_classes"]["name"] || "None provided.",
ticketClassesCost: events[i]["ticket_classes"]["cost"] || "It's freeee!",
ticketClassesDescription: events[i]["ticket_classes"]["description"] || "None provided."
}, {
答案 1 :(得分:0)
票证类实际上是一个数组,为了访问它,我必须向httpRequest添加一个expand参数,除了代码本身没问题,thx Tushar用于语法修正。