Page routing ( coming from which page)

I want to know how to get previous page route. e.g
If i create new payment entry from supplier, how do i know i am coming from supplier. so that i can set few defaults.

const prev_route = frappe.get_prev_route();
    const prev_doctype = prev_route[1];
    const prev_docname = prev_route[2];