try to do it with async/await:
async function getCustomerId(name) {
var output;
let response = await fetch('https://jsonplaceholder.typicode.com/todos/1');
if (response.status !== 200) {
console.log("Looks like there was a problem. Status Code: " + response.status);
} else {
const data = await response.json()
//console.log("CustomerId:" + data.id);
output = data.id;
console.log(data.id)
}
console.log(output);
}
getCustomerId()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…