在node.js中使用fetch

 const url = "http://127.0.0.1:3001/createAccount";
        fetch(url, {
            method: "POST",
            mode: "cors",
            body:"pwd=sdd",
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }

        }).then(response => response.json())
            .then(result => {
                // 在此处写获取数据之后的处理逻辑
                console.log(result);
            }).catch(function (e) {
            //console.log("fetch fail", JSON.stringify(params));
            alert(e);
        });
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注