0
的特性 '切片',而做了一些反應,服務器端與終極版愛可信:無法讀取得到這個錯誤空
堆棧跟蹤
TypeError: Cannot read property 'slice' of null
at dispatchHttpRequest (E:\Projects\real-estate\node_modules\axios\lib\adapters\http.js:84:37)
at httpAdapter (E:\Projects\real-estate\node_modules\axios\lib\adapters\http.js:19:10)
at dispatchRequest (E:\Projects\real-estate\node_modules\axios\lib\core\dispatchRequest.js:52:10)
at process._tickCallback (internal/process/next_tick.js:103:7)
行動
import axios from 'axios';
export const FETCH_USER = 'FETCH_USER';
export const FETCH_POSTS = 'FETCH_POSTS';
const GET_POSTS_URI = '/api/posts';
export const fetchPosts =() => {
let posts = axios.get(GET_POSTS_URI).catch(err => console.log(err));
return {
type: FETCH_POSTS,
payload: posts
}
}
API
渲染app.get('/api/posts', function(req, res, next) {
Post.model.find()
.exec()
.then(function(posts) {
res.send(posts);
}, function(err) {
return next(err);
});
})
我還有在開發工具的網絡選項卡中的JSON響應,但我無法檢索減速器中的JSON響應。我也沒有得到這個錯誤,當我使用OpenWeatherAPI