MetricConverter: res.json is empty

api.js

    console.log(initNum);
    console.log(initUnit);
    console.log(returnNum);
    console.log(returnUnit);
    console.log(toString);
    
    res.json({initNum:initNum,initUnit:initUnit,returnNum:returnNum,returnUnit:returnUnit,toString:toString});

functional-test.js

 test("Convert 3/7.2/4kg (invalid number)", function(done) {
           chai
          .request(server)
          .get("/api/convert")
          .query({ input: "3/7.2/4kg" })
          .end(function(err, res) {
             console.log(res.body);
            assert.equal(res.status, 200);
            assert.equal(res.body.initNum, undefined);
            assert.equal(res.body.initUnit, "kg");
            assert.equal(res.body.returnNum,undefined);
            assert.equal(res.body.returnUnit, "lbs");
            done();
          });
      });

values are printed on the console but res.json returns {} when I console.log it console.log(res.body);

logs

kg

undefined

kg

undefined

lbs

undefined

{}

editable code

challenge link
https://www.freecodecamp.org/learn/quality-assurance/quality-assurance-projects/metric-imperial-converter

I found an issue simlair to ure issue: which might help u out

1 Like