search

Home  >  Q&A  >  body text

Axios GET request was modified by something in the frontend

In this action I have a basic GET response on the URL "api/media/action"

export const listWorks = async (dispatch) => {
    try{
        dispatch({type:WORK_LIST_REQUEST})
        const { data } = await axios.get('api/media/works/')
        
        

        dispatch({type:WORK_LIST_SUCCESS,
        payload:data})

    } catch(error) {
        dispatch({type:WORK_LIST_FAIL,
        payload: error.response && error.response.data.detail 
        ? error.response.data.detail
        : error.message
    
    })
}

}

In App.js, routing is defined as:

<Route path='/work/:name'component={WorkScreen}/>

By launching the action, I received the following error on the backend:

[26/Jul/2023 20:47:24] "GET /work/api/media/works/ HTTP/1.1" 404 2712

I don't understand why "work" is added to the GET request

P粉195200437P粉195200437434 days ago608

reply all(1)I'll reply

  • P粉482108310

    P粉4821083102023-09-21 00:15:25

    URL `api/media/works/` is a relative path. It does not begin with `http://` or `https://` and is therefore treated as a path relative to the current URL from which the API call was made.

    Try making the same request using an absolute URL starting with `http://` or `https://`.

    reply
    0
  • Cancelreply