作者:乔志造型店长阿杰 | 来源:互联网 | 2023-08-23 17:00
试图遵循教程How to build an API with Lambdas and API Gateway并遇到一些错误:
尝试了很长时间。将json添加到代码编辑器中时,错误的任何解释?
exports.handler = async (event) => {
console.log(event);
if (event.httpMethod === 'PUT') {
let respOnse= putShows(event)
return done(response);
} else if (event.httpMethod === 'GET') {
let respOnse= getShows(event);
return done(response);
}
};
const dOne= respOnse=> {
return {
statusCode: '200',body: JSON.stringify(response),headers: {
'Content-Type': 'application/json','access-Control-Allow-Methods': '*','access-control-allow-origin': '*'
}
}
}
const Showss = {
action: 'Game of Thrones',fantasy: 'Supernatural',animated: 'The Simpsons',western: 'Westworld',superhero: 'The flash',musical: '30 Rock',crime: 'Sherlock',comedy: 'Friends',adventure: 'Doctor Who',war: 'Wounded Love',guy: 'The Walking Dead',romance: "Grey's Anatomy",thriller: 'Sharp Objects',horror: 'American Horror Story'
}
const getShows = event => {
let genre = event.pathParameters.genre;
return Showss[genre];
}
const putShows = event => {
return;
}
先谢谢了。
您可以尝试其他浏览器或清除浏览器中的缓存。