AnsweredAssumed Answered

Accessing APIs via JavaScript

Question asked by Sepehr Malek on Mar 21, 2018
Latest reply on Mar 22, 2018 by Sepehr Malek



We are designing a page with a few buttons linked to different pages within a course. We want the buttons to only appear when the pages they are linked to are published.


The way I'm trying to achieve this is to access the APIs with the custom javascript and check if the page is published or not. I've done some testing with the code bellow:


$.getJSON("/api/v1/courses/:courseID/pages", function(data) { x = data; });

      for (i in x) {

                        console.log(x[i]["title"] + " - " + x[i]["published"]);



The problem is when I login as the student, this code wont show me any results which I think its because the student account doesn't have access to unpublished pages. Which means I have to call the APIs with an access token which I do not want to put in the custom javascript.

When I run the script above in my own account (admin), I get the result I need, though, it only show me 10 item in the results. I have more than 10 pages in the course.


I'd really appreciate some insight if anyone can help.