Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created May 31, 2021 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuc-arc-f/9167f32781d469b670bcef357741e9d2 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/9167f32781d469b670bcef357741e9d2 to your computer and use it in GitHub Desktop.
sapper, get query sample
// 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