Mobile detection not working

I have a manual transcribing tool and I have used an npm package called express-device. This package detects the device used by the user and acts accordingly. I want it in a way, such that, if the device is a mobile, it will go to another HTML file designed for the mobile device. The code I’ve entered looks like this:

app.get("/", function(request, response) {
  var type = request.device.type;
  if (type === "mobile") {
    response.sendFile(__dirname + "/views/mobile.html");  
  } else {
    response.sendFile(__dirname + "/views/index.html");  
  } 
});

but for some the reason, the website isn’t navigated to the mobile page.

You can view the code here in the server.js file.

Hi @khalby786! I remixed your project and took a look at express-device. I think your issue is the string that you’re using to compare types. I replaced (type === "mobile") with (type === "phone") and it worked for me – cool project! :slight_smile:

2 Likes

Guess I hadn’t been careful…