BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / postjson.js

postjson.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
postjson.js 472 B Download Raw
1// Example using HTTP POST operation
2
3"use strict";
4var page = require('webpage').create(),
5 server = 'http://posttestserver.com/post.php?dump',
6 data = '{"universe": "expanding", "answer": 42}';
7
8var headers = {
9 "Content-Type": "application/json"
10}
11
12page.open(server, 'post', data, headers, function (status) {
13 if (status !== 'success') {
14 console.log('Unable to post!');
15 } else {
16 console.log(page.content);
17 }
18 phantom.exit();
19});