const url = "http://sjhtest.musicen.com/ping/same/1"
const options = {
method: "POST",
headers: { "content-type": "application/json"},
body: JSON.stringify({ a: 1, b: 2, })
}
fetch(url, options).then(r=>r.json()).then(d => alert(JSON.stringify(d)))
------------OR------------
fetch("http://sjhtest.musicen.com/ping/same/1", { method: "POST", headers: { "content-type": "application/json", },
body: JSON.stringify({ a: 1, b: 2, }), }).then(r=>r.json()).then(d => alert(JSON.stringify(d)))
n초후 같은 json 그대로리턴
fetch("http://sjhtest.musicen.com/ping/sameErr/1", { method: "POST", headers: { "content-type": "application/json",
}, body: JSON.stringify({ a: 1, b: 2, }), }).then(r=>r.json()).then(d => alert(JSON.stringify(d)))
에러남 -> fetch("https://www.naver.com")
----에러 안남----
const jsonBody = {
endPoint: "https://www.naver.com",
method: "GET",
headerData: {
},
bodyData: "",
};
fetch("/skipCors", {
method: "POST", // *GET, POST, PUT, DELETE, etc.
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(jsonBody), // body data type must match "Content-Type" header
}).then(r=>r.text()).then(d => alert(d.slice(0,100)))
-------한줄로 정리----------
fetch("/skipCors", {method: "POST", headers: {"Content-Type": "application/json",},body: JSON.stringify({endPoint: "https://www.naver.com",method: "GET",headerData: {},bodyData: "",}), }).then(r=>r.text()).then(d => alert(d.slice(0,100)))
pm2 리스타트 하는 방법
pm2 restart testserver // 라이브러리(ex dayjs)같은거없어서 리로드안될수있음
pm2 restart all