Unable to fetch when using http in flutter get request but postman is working well

Viewed 27

I am trying to replicate how i post using postman which returns the correct data but when i use this i errors i have looked with no success can anyone help

POSTMAN

http://localhost:1234/architecture/api/v1/client_academic_achievements/:id?3

NODE CONSOLE LOG
no of records is 1
RESPONDING

THIS WORKS VERY WELL

THEN HERE IS THE FLUTTER HTTP GET WHICH BRINGS AN ERROR

 Future<void> yes() async {
Future yes() async {
    var queryParameters = {
      'id': '${widget.itemData.id.toString()}',
    };
    var uri =Uri.http('IP_ADDRESS:1234', '/architecture/api/v1/client_academic_achievements/:', queryParameters);
    print(uri);
    print("THE URI IS $uri");
    var response = await http.get(uri);
    if(response.body.isNotEmpty) {
      json.decode(response.body);
    }
    else{
      print("empty body found");
    }}
CONSOLE.LOG NODE
no of records is 0
RESPONDING

THE SQL QUERY FROM BACKEND

router.get('/client_academic_achievements/:id', async (req, res) => {
    console.log("ACESSING",req.params.id);

    const sql = "SELECT start_year,end_year,school_attended FROM " + TABLE_NAME_2 + ' INNER JOIN '+
    TABLE_NAME_3+' ON '+TABLE_NAME_2+'.id = '+TABLE_NAME_3+'.id AND ' + TABLE_NAME_2 + '.id = ?';
    await connection.query(sql,[req.params.id], (err, rows) => {
        console.log('Connection result error: ' + err);
        console.log('no of records is ' + rows.length);
        console.log("RESPONDING");
 res.send(rows[0]);
    });});
0 Answers
Related