Created
May 31, 2021 06:53
-
-
Save kuc-arc-f/9167f32781d469b670bcef357741e9d2 to your computer and use it in GitHub Desktop.
sapper, get query sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sapper, get query sample | |
// URL : http://localhost:3000/api/query?hoge=1&fuga=2 | |
// | |
export async function get(req, res) { | |
try{ | |
console.log( req.query ) | |
console.log( "hoge=", req.query.hoge ) | |
console.log( "fuga=", req.query.fuga ) | |
res.writeHead(200, { | |
'Content-Type': 'application/json' | |
}); | |
res.end(JSON.stringify([])); | |
} catch (err) { | |
console.error(err); | |
res.writeHead(500, {'Content-Type': 'application/json' }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment