响应未反映变化
Response not reflecting changes
我遇到了一些非常奇怪的事情 behavior.The 应用程序运行良好,然后即使我更改了房间 ID,响应也没有任何变化。
我什至尝试删除 app.get() 方法并调用该路由 /api/availability,响应仍然弹出
app.get("/api/availability", (req, res) => {
res.json({ availability : availableroomsArray});});
无论我调用什么,我都会得到相同的旧响应,将路由更改为 /api/available 而不是 /api/availability 将在 /api/availability.
中显示相同的响应
这是我的代码:
var availableroomsArray = [];
var arrayAll = [];
var rooms =[];
var roomIds=[9748,7264,59038,110158,42714]
var obj = {};
const start = async function() {
// GET THE ROOMS
const body = {propId: "3578",
roomId: true};
const response =await fetch('https://api.beds24.com/json/getDescriptions', {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});
const data = await response.json();
for (let i in roomIds) {
arrayAll.push(data["properties"]["rooms"][roomIds[i]]);
app.get("/api/rooms", (req, res) => {
res.json({ rooms: arrayAll});});
}
var from=await dateFormat(Date.now(), "yyyymmdd");
console.log("aa"+from);
var to=await dateFormat(new Date(new Date().setFullYear(new Date().getFullYear() + 1)), "yyyymmdd");
console.log("aa"+to);
//GET ROOM'S AVAILABILITY
for (let i in roomIds) {
const AvailBody = {"authentication": {
"apiKey": "privatekey",
"propKey": "privatekey"
},
"from": from, // datenow w format
"to": to,
"roomId": roomIds[i]
};
const AvailResponse =await fetch('https://api.beds24.com/json/getRoomDates', {
method: 'post',
body: JSON.stringify(AvailBody),
headers: {'Content-Type': 'application/json'}
});
var indicateur = roomIds[i]
const Availabilitydata = await AvailResponse.json();
obj[roomIds[i]] = Availabilitydata;
}
availableroomsArray.push(obj);
app.post("/api/availability", (req, res) => {
res.json({ availability : availableroomsArray});});
}
我是 运行 错误的项目,正在编辑另一个项目,它们确实同名。
我遇到了一些非常奇怪的事情 behavior.The 应用程序运行良好,然后即使我更改了房间 ID,响应也没有任何变化。 我什至尝试删除 app.get() 方法并调用该路由 /api/availability,响应仍然弹出
app.get("/api/availability", (req, res) => {
res.json({ availability : availableroomsArray});});
无论我调用什么,我都会得到相同的旧响应,将路由更改为 /api/available 而不是 /api/availability 将在 /api/availability.
中显示相同的响应这是我的代码:
var availableroomsArray = [];
var arrayAll = [];
var rooms =[];
var roomIds=[9748,7264,59038,110158,42714]
var obj = {};
const start = async function() {
// GET THE ROOMS
const body = {propId: "3578",
roomId: true};
const response =await fetch('https://api.beds24.com/json/getDescriptions', {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});
const data = await response.json();
for (let i in roomIds) {
arrayAll.push(data["properties"]["rooms"][roomIds[i]]);
app.get("/api/rooms", (req, res) => {
res.json({ rooms: arrayAll});});
}
var from=await dateFormat(Date.now(), "yyyymmdd");
console.log("aa"+from);
var to=await dateFormat(new Date(new Date().setFullYear(new Date().getFullYear() + 1)), "yyyymmdd");
console.log("aa"+to);
//GET ROOM'S AVAILABILITY
for (let i in roomIds) {
const AvailBody = {"authentication": {
"apiKey": "privatekey",
"propKey": "privatekey"
},
"from": from, // datenow w format
"to": to,
"roomId": roomIds[i]
};
const AvailResponse =await fetch('https://api.beds24.com/json/getRoomDates', {
method: 'post',
body: JSON.stringify(AvailBody),
headers: {'Content-Type': 'application/json'}
});
var indicateur = roomIds[i]
const Availabilitydata = await AvailResponse.json();
obj[roomIds[i]] = Availabilitydata;
}
availableroomsArray.push(obj);
app.post("/api/availability", (req, res) => {
res.json({ availability : availableroomsArray});});
}
我是 运行 错误的项目,正在编辑另一个项目,它们确实同名。