1

I cannot get the schoology API to work and the documentation that they posted does not tell me whether the API is depricated or not. Also I keep getting network errors but I highly doubt that it is client side and I think it is server side which would indicate that the API is not working.

Here is my code

import React, { useState, useEffect } from "react";

const API_KEY = "72f0fef42061705869c0d0a8d971b2b0063e32423";
const API_SECRET = "03260a5f78a194fb7b0de3bb05893254";
const API_URL = "https://api.schoology.com/v1/assignments";

function App() {
  const [assignments, setAssignments] = useState([]);

  useEffect(() => {
    const fetchAssignments = async () => {
      const response = await fetch(API_URL, {
        headers: {
          Authorization: `OAuth realm="Schoology API", oauth_consumer_key="${API_KEY}", oauth_token="${API_SECRET}"`,
        },
      });
      const data = await response.json();
      setAssignments(data.assignments);
    };

    fetchAssignments();
  }, []);

  return (
    <div>
      <h1>Assignments</h1>
      <ul>
        {assignments.map((assignment) => (
          <li key={assignment.id}>{assignment.title}</li>
        ))}
      </ul>
    </div>
  );
}

export default App;

HarenP
  • 11
  • 1

0 Answers0