我使用TMDB API实现了一个ReactJS应用程序,我还使用了2.2.1版的Webpack,我随机得到以下错误消息:=> net ::ERR_CONTENT_DECODING_FAILED 200 (OK)。
这可能是我发送了太多的数据,gzip压缩是必要的,但我不确定。
正如我所说的,这是一个并不总是发生的错误,但它通常是关于=>的同一个axios查询
async fetchMovies () {
this.setState({ isLoading:true})
const promises = genres.map(async genre => {
const response = await getMoviesWithGenresFromApi(genre.id).then(data
=> {
return data.results.slice(0,14)
})
return {
movies:response,
genretitle:genre.name,
id:genre.id
}
});
const result = await Promise.all(promises).then((result) => {
this.setState({
movieListWithGenre:result,
hasMore: (this.state.movieListWithGenre.length < 19),
isLoading:false
})
});
}AXIOS请求:
export function getMoviesWithGenresFromApi(id_genre){
return axios.get(`https://api.themoviedb.org/3/discover/movie?api_key={api_key}&sort_by=popularity.desc&language=fr&include_adult=false&include_video=false&with_genres=${id_genre}`)
.then((response) => response.data)
.catch((error) => console.error(error))
}我想确定这个错误是从哪里来的,以及采取什么解决方案来纠正这个错误。
发布于 2020-05-08 21:56:52
我也遇到过类似的问题。我使用的是JDK 1.8.0_144,它在压缩方面有问题。此错误已在以后的版本中修复。JDK 1.8.0_202帮我解决了这个问题。
发布于 2021-04-09 03:04:07
我在使用JDK 1.8.0_192时遇到了这个问题--对我来说,问题是我多次添加了相同的头文件集(Content-Encoding = gzip)
response.addHeader(“内容编码”,"gzip");
https://stackoverflow.com/questions/56954461
复制相似问题