async
var fs = require('fs'); var queryString = require("querystring"); var fetch = require('node-fetch'); var list = fs.readFileSync("title.sql.txt","utf-8"); list = list.split("\r\n"); async function apiPost( text ){ var formData = { text : text , types : 'head' , lens : 1 , level : 6 }; formData = queryString.stringify(formData); var opts = { method:"POST", body:formData, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } } let ret = await fetch('http://60.205.105.147/nlpir/',opts) .then((res) => { return res.json(); }) .then((json) => { return json ; }) .catch((error) => { console.log(error); return {error:1}; }); return ret ; } async function run(){ var text = {}; for(i=0;i<200;i++){ title = list.shift(); text[ i ] = title ; i++; } var m = await apiPost(JSON.stringify(text)); console.log(m.head,m.limitTime,m.msg); } run();