0

Situation - looping over array of events and assigning properties from JSON parsed

Expected outcome - upload to Parse cloud storage

APIs that I'm using -

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

I'm new to Javascript (there actually might be more than one syntax error)

I don't know why I get this error on line 83 when trying to deploy to Parse Cloud Code

What I'm passing in -

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

loopEvents(eventsArray);

the whole function as screenshot (syntax highlighting for readability) --> code

the function as text -->

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

maybe it's all wrong, appreciate the effort and constructive answers ;))) if you need any other info just comment bellow and I'll edit.

EDIT.1 - after replacing ; for , I get the following error

2 Answers 2

1

As you're using object, semi-colon ; is not valid syntax.

Remove ; from all the lines inside the object.

number: String(i);
//               ^

Use , comma instead.

number: String(i),
//               ^

Code

// 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."
}, {

See Object creation

Sign up to request clarification or add additional context in comments.

2 Comments

@Ferologics How do you expect us to solve the error, without seeing your code
it's the same but without the semicolon. @Tushar
0

ticket classes is actually an array and to access it I had to add a expand parameter to the httpRequest, other than that the code itself was fine, thx Tushar for the syntax correction.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.