GA4 analytics data api gives html report instead of json

i am trying to fetch data from analytics data api, but my web page keep showing Error fetching data: SyntaxError: Unexpected token ‘<‘, “<!DOCTYPE “… is not valid JSON, i tried to test the type of file got from api, it is always html, and i tried many ways to convert this html into json, but it always fail, so I wonder what should I do to fix it. Thannk you so much for the help.

my server code:

part1
part2

my client code:

part1

thank you, i used postman to test it, it has a response, but just in html form.

i tried to convert it into json in server side, but it didn’t work, and I tested it on web using inspect as well, still html.

so now I think the main problem is that the html response got from api won;t convert into json.