gpt4 book ai didi

javascript - 未捕获的语法错误 : Unexpected token - Cloud Code Parse save function

转载 作者:行者123 更新时间:2023-12-03 09:32:09 25 4
gpt4 key购买 nike

情况 - 循环事件数组并从解析的 JSON 分配属性

预期结果 - 上传到 Parse 云存储

我正在使用的 API -

https://www.eventbrite.com/developer/v3/formats/event/#ebapi-std:format-event https://www.parse.com/docs/js/guide

我是 Javascript 新手(实际上可能存在多个语法错误)

我不知道为什么会收到这个 error尝试部署到 Parse Cloud Code 时位于第 83 行

我要传递的内容 -

var cities = ["San Francisco", "London"];
eventsArray = JSON.parse(httpResponse.text)["events"];

loopEvents(eventsArray);
<小时/>

整个函数如屏幕截图(语法突出显示以提高可读性)--> code

作为文本的函数 -->

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++;
}

也许这都是错的,感谢您的努力和建设性答案;)))如果您需要任何其他信息,请在下面评论,我会编辑。

EDIT.1 - 替换后;对于 ,我得到以下 error

最佳答案

由于您使用的是 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."
}, {

参见Object creation

关于javascript - 未捕获的语法错误 : Unexpected token - Cloud Code Parse save function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31469971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com