我每次刷新页面时都可以将json数据存储在数组中吗

时间:2019-06-05 23:22:05

标签: javascript node.js express express-router

当我返回上一条路线时,在此行中出现错误 meals = data.meals.map(meal => meal);

  

类型错误,无法读取null的属性“ map”

request(options, (error, response, body) => {
    const data = JSON.parse(response.body);

    if (error) {
        console.log(error);
    } else {
        const meals = data.meals.map(meal => meal);
        console.log(response.statusCode);
        res.render("result", { categories: meals, title: category });
    }
});

enter image description here

0 个答案:

没有答案