First I got "Error: Server responded with status code 403" when i tried to print the statusCode.
Adding headers like 'User-Agent'
and 'Accept'
helps the server accept your request and respond with the data you expect.( i told chatgpt to give me headers )
var response = await http.get(
Uri.parse("https://jsonplaceholder.typicode.com/posts"),
headers: {
'User-Agent': 'Mozilla/5.0',
'Accept': 'application/json',
},
);