0

the code is:

@app.route("/login/search/<int:book_id>",methods=["POST","GET"])
def book(book_id):
 desc=db.execute("SELECT * from books where id = :id",{"id":book_id}).fetchone()
 isbns=desc.isbn
 reviews=db.execute("SELECT review from reviews where books_id = :id",{"id":book_id}).fetchall()
 res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": "b1J7lLvE", "isbns":"isbns"})
 data = res.json()
 newDict={}
 for item in data['books']:
  newDict.update(item)
 data['books']=newDict
 avg_rating=data['books']['average_rating']
 review_count=data['books']['work_reviews_count']
 return render_template('book.html',desc=desc,reviews=reviews,rate=avg_rating,count=review_count)

the error says :

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

can anyone make out why this is happening? . Thanks in advance

1 Answers1

0

In your code when you call

res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": "b1J7lLvE", "isbns":"isbns"})
print(res.content)

Your output is:

b'Invalid API key.\n<!-- This is a random-length HTML comment: tgmijslzfwfkbktnapqxedcbllosvgcyaanmcyzhputsuerpqcpiomckurucullmhzgfbdddyxqxpykpbvilzwfmndmpqdxyyqnwamyoazzzudlkogidzxgegvizcmyylshgsrsognjlfsnwyvkvjcbhshtlghswbitidntlbpdzhdgunwroofflbunfhnazakyfkixrtlmeqpfaowzgxkffbekfghpkyrfatjyackvcznfeaaotljhwdexrgwfxbpvrdkbqvnuaxcrfmxhkzdvkbxhenxfnmgwdgkkdkgmlobngwklrsygaiendstpdgaewqencjyxienvcxcdfmpavdzmjyplgv -->'

This response doesn't have a JSON format and that's apparently your problem. JSONDecoder expects a string that contains the format that it expects from the genre

'{"name": "John", "age": 30, "city": "New York"}'

Check if your response is in a format readable by JSON Decoder and if so and the problem persists, report.

Pikaxhuu
  • 1
  • 2