Node/Express: How to avoid status code 302 from a POST request made from a redirect button

I am trying to achieve a button that allows the client to navigate to and and from 2 sets of “to do lists”.

I want the button name to say “Home” when on the works to do list, and “Work” when on the home to do list page. and to navigate to and from these pages using just the one button.

I am using node, express and EJS, and my current attempt at making this work is to create an HTML button witch sends a post request to a “divert” route, and then executing a conditional statement to decide which route to redirect to depending on what the current page title is.

However i can redirect from the home page to the work page but once there i can not redirect back to the home page!.

console shows a 302 status code the moment i click the button to redirect me a second time. (from work to home.

I am a freshman on node and Express!

My codes below,

HTML

`<%- include("header") -%>    
<div class="box" id="heading">
<h1><%=listTitle%></h1>
</div>

<div class="box">
<% for (let i =0; i< newListItems.length; i++) { %>
<div class="item">
<input type="checkbox">
<p><%= newListItems[i] %></p>
</div>
<% }; %>

<form class="item" action="/" method="post">
<input type="text" name="newItem" placeholder="New item?" autocomplete="off">
<button type="submit" name="list" value=<%= listTitle %>>+</button>
</form>

</div>

<form class="" action="/divert" method="post">
<button type="submit" class="btn1" name="todoType" value="identify" style="width: 
100px"><%=btnName%></button>
</form> 

<%- include("footer") -%>`

app.js

`//jshint esversion:6

const express = require("express");
const bodyParser = require("body-parser");

// globals.
let items = [];
let workItems = [];
let btnIdentify = "Work";

const app = express();
app.use(bodyParser.urlencoded({extended: true}));

//Send static css file to browser.
app.use(express.static("public"));

app.set('view engine', 'ejs');


app.get("/", function(req, res) {
const date = new Date();
const options = {
weekday: "long",
day: "numeric",
month: "long"
};

let day = date.toLocaleDateString("en-US", options);
res.render('list', {listTitle: day, newListItems: items, btnName: btnIdentify});
});


app.post("/", function(req, res) {
let item = req.body.newItem;

if (req.body.list === "Work")  { //only uses frist word off the listTitle value.
workItems.push(item);
res.redirect("/work");
} else {
items.push(item);
res.redirect("/");
}
console.log(req.body);
})

app.get("/work", function(req,res) {

res.render("list", {listTitle: "Work list", newListItems: workItems, btnName: btnIdentify });
});

app.post("/divert", function(req,res) {
if (req.body.list !== "Work") {
res.redirect("/work");
btnIdentify = "Work";
} else if (req.body.list === "Work") {
res.redirect("/");
btnIdentify = "Home";
}
})

app.listen(3000, function() {
console.log("Server is running on port 3000")
});`