TypeError: Converting circular structure to JSON and Uncaught (in promise) TypeError: this.activeCallback is not a function

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

Hello guys, I am currently having this problem but I cannot seem to figure out the solution:

I have this function:

// initialize
const [title, setTitle] = useState('');
const [isRecyclable, setIsRecyclable] = useState('');

// function
  const handleSubmitData = (e) => {
    e.preventDefault();
    fetch('https://recycling-barcode-api.herokuapp.com/database)
      .then(response => response.json())
      .then((responseJson) => {
        console.log(responseJson);
        responseJson.forEach((item) => {
          if (title === item['title']) {
            setIsRecyclable(item['isRecyclable']);
          } else {
            setIsRecyclable('Item not found')
          }
        })
      })
      .catch(err => console.error(err));
  }

// database
{
    "database": [
        {
            "title": "Coca-Cola Life Soda Soft Drink, 7.5 Fl Oz, 6 Pack",
            "isRecyclable": true
        },
        {
            "title": "Coca-Cola Rare Napkin Tray with Bottle Handle with Coca-Cola Napkins",
            "isRecyclable": true
        },
        {
            "title": "Samsung 970 EVO Plus 1TB SSD (MZ-V7S1T0B/AM)",
            "isRecyclable": false
        },
        {
            "title": "Macbook Pro",
            "isRecyclable": false
        },
        {
            "title": "Kids Water Bottles Bulk, Portable Travel Bottle Water Cup Leak-proof Plastic Sports Straw Cup Bottle, Material Plastic",
            "isRecyclable": true
        }
    ]
}

—> so the object returns as an array and I want to loop through the array to see if the title matches with the title in the database. But it gives me this error:

TypeError: Converting circular structure to JSON
Uncaught (in promise) TypeError: this.activeCallback is not a function

----Do you know why? Please help! thank you

This article may be of help: what-is-typeerror-converting-circular-structure-to-json