score:0

Accepted answer

You can give the approach below a whirl.

export const getUserOrders = async userId => {
      const header = {
        "Content-Type": "application/json;charset=utf-8",    
      };
      let id = userId;
      const URL = `http://127.0.0.1:8000/admindashboard/userorders/`
      return dispatch => {
        try {
          dispatch(getUserOrdersStart())

           const response = await axios(URL,id, {
            method: "GET",
            mode: "cors",
            headers: header,

          });
          const jsonResponse = response.json();
          dispatch(getUserOrdersSuccess(order))
        } catch (error) {
          setError(error);
        }
      };

score:0

Try adding CORS headers

Use this package and read the docs

https://github.com/adamchainz/django-cors-headers


Related Query

More Query from same tag