Quiero inciar mi frontend y me salen los siguientes errores y no se como solucionarlos.
Primero voy a mostrar mi documento Fetch.js
const baseURL = process.env.REACT_APP_API_URL
export const fetchWithoutToken = ( endpoint, data, method='GET' ) => {
const url = `${ baseURL }/${ endpoint }`;
if ( method === 'GET' ){
return fetch( url );
} else {
return fetch( url , {
method,
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify( data )
});
}
}
export const fetchWithToken = ( endpoint, data, method = 'GET' ) => {
const url = `${ baseURL }/${ endpoint }`;
const token = localStorage.getItem('token') || '';
if ( method === 'GET' ){
return fetch( url,{
method,
headers: {
'Authorization': `Token ${ token }`
}
});
} else {
return fetch( url , {
method,
headers: {
'Content-type': 'application/json',
//'token': token
'Authorization': `Token ${ token }`
},
body: JSON.stringify( data )
});
}
}
Ahora los errores:
GET http://localhost:8000/refresh-token/ net::ERR_CONNECTION_REFUSED
ncaught (in promise) TypeError: Failed to fetch
at fetchWithToken (fetch.js:29:1)
at auth.js:44:1
at index.js:16:1
at AppRouter.js:26:1
at invokePassiveEffectCreate (react-dom.development.js:23487:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
at invokeGuardedCallback (react-dom.development.js:4056:1)
at flushPassiveEffectsImpl (react-dom.development.js:23574:1)
at unstable_runWithPriority (scheduler.development.js:468:1)
at runWithPriority$1 (react-dom.development.js:11276:1)
at flushPassiveEffects (react-dom.development.js:23447:1)
at react-dom.development.js:23324:1
at workLoop (scheduler.development.js:417:1)
at flushWork (scheduler.development.js:390:1)
at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)
Saludos y gracias por su tiempo