Created
August 7, 2016 17:37
-
-
Save lv7777/4986a626a2ae1bbb850db83ec0397021 to your computer and use it in GitHub Desktop.
fetch()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hear=new Headers({ | |
"Content-Type":"image/png", | |
"Accept":"*/*", | |
"Connection":"keep-alive" | |
}) | |
var myinit2={ | |
method:"GET", | |
header:hear | |
} | |
fetch("/img/icons/logo.png",myinit2).then(response=>{if(response.ok){return response.blob();}}).then(data=>console.log(URL.createObjectURL(data))); | |
// できない・・・ちゃんと動くけど | |
function testes(str="error"){ | |
console.log(str);var imp=document.getElementById("originalTextArea");imp.value=str; | |
} | |
function translate(cb=testes){ | |
const he=new Headers({ | |
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", | |
"Accept-Encoding": "gzip, deflate", | |
"Cookie": "optimizelyEndUserId=oeu1466180228566r0.8957759570224985; _ga=GA1.2.1775585478.1466180232; mfids=uid1[746:0100007F87226457F05ED061023C378F]uid3[0100007F87226457F05ED061023C378F]; __gads=ID=a0070c832644b8b0:T=1466180247:S=ALNI_MZDcqCZhEcY-xGN2qN2TveqOW7nVQ; qsf=true; optimizelySegments=%7B%222007740035%22%3A%22ff%22%2C%222020280600%22%3A%22false%22%2C%222022830235%22%3A%22search%22%2C%224946901459%22%3A%22none%22%7D; optimizelyBuckets=%7B%7D", | |
"Connection": "keep-alive" | |
}) | |
const forms=new FormData(); | |
forms.set("originalText","preciedence"); | |
forms.set("lp","EJ"); | |
const init={ | |
method:"post", | |
header:he, | |
body:forms | |
} | |
fetch("/",init).then(response=>{ | |
if(response.ok){ | |
return response.text(); | |
}else{ | |
throw Error("eeeeeee rrrrrrorroror"); | |
} | |
}).then(data=>{ | |
cb(data); | |
}).catch(err=>{ | |
console.log(err); | |
}) | |
} | |
translate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment