Get dcc.Location string


I am trying to get the string of the path by using dcc,Location, but instead a list is being returned. Is there a way I can just get a string by using dcc.location


layout = html.Div([
    dcc.Location(id="url1", refresh=True)
], id="404")
    Output("url1", "pathname"),
    Input("404", "children")
def checkID(url):
    global df
    url = str(url)
    url = url.replace("/", "")
    for i,row in df.iterrows():
        crimeId = str(row.CrimeID)
        if url == crimeId:
            return mapPublic.layout
    raise PreventUpdate

What is printed:

[{'props': {'id': 'url1', 'refresh': True, 'pathname': '/4102021Chelmsford', 'href': '', 'hash': '', 'search': ''}, 'type': 'Location', 'namespace': 'dash_core_components'}]

Thank you

1 Like

does this help?

1 Like

Thank you, that helped, but I later noticed I had switched up my Input/Output accidentally, causing my url variable to equal the dcc.Location component, not the pathname