export const getMovies = (text) => async (dispatch) => {
try {
const res = await axios.get(
`https://api.themoviedb.org/4/search/movie?api_key=${process.env.REACT_APP_API_KEY}&language=en-us&page=1&include_adult&query=${text}` );
dispatch({
type: GET_MOVIES,
payload: res.data,
});
} catch (err) {
console.error(err);
}
};
在REACT / REDUX项目中运行以下代码行时遇到以下错误:
Access to XMLHttpRequest at 'https://api.themoviedb.org/4/search/movie?api_key=b1d71b9e30e9e87132c7a808864f227c&language=en-us&page=1&include_adult&query='
from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field auth-token is not
allowed by Access-Control-Allow-Headers in preflight response.
对于解决此错误的任何投入,我们将不胜感激。