自分用めも

初心者ちっくなプログラムネタを中心に、自分用の覚え書きをメモっていくための場所です。

PerlでaxiosからJSONを受け取る

axios初めて使ったんですが、ものすごい簡単でびっくりしました。。

axios
GitHub - axios/axios: Promise based HTTP client for the browser and node.js

axios.post(
	'./index.cgi', {
		"key": "value"
	}
).then(
	response => {
		console.log(response.data.key);
	}
).catch(
	error => {
		console.log(error)
		this.errored = true
	}
).finally(
	() => this.loading = false
);

Perl
CGI - metacpan.org

use CGI;
use JSON::XS;

my $param = decode_json($cgi->param('POSTDATA'));
print $param->{key};