Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created May 31, 2021
Embed
What would you like to do?
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