简体   繁体   English

如何在 NodeJS 中发送 ZAP post 请求?

[英]How to send a ZAP post request in NodeJS?

My url is like this:我的url是这样的:

https://hooks.zapier.com/hooks/catch/2020200/jasoa43

What will be my code?我的代码是什么? How to get the port and what will be the path?如何获取端口以及路径是什么? Please check the following code and let me know what would be those parameters.请检查以下代码,让我知道这些参数是什么。

const https = require('https')

        const data = 'data'
     
        const options = {
            hostname: ??,
            port: ??,
            path: ??,
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': data.length
            }
        }

        const req = https.request(options, res => {
            console.log(`statusCode: ${res.statusCode}`)

            res.on('data', d => {
                process.stdout.write(d)
            })
        })

        req.on('error', error => {
            console.error(error)
        })

        req.write(data)
        req.end()
 const https = require('https')

        const data = JSON.stringify({
         
            pin:change.after.data().pin,
            name:change.after.data().firstName,
            email:change.after.data().email,
            phone:change.after.data().phone,

        });
     
        const options = {
            hostname: 'hooks.zapier.com',
            port: 443,
            path: '/hooks/catch/5977644/ofrda44',
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': data.length
            }
        }

        const req = https.request(options, res => {
            console.log(`statusCode: ${res.statusCode}`)

            res.on('data', d => {
                process.stdout.write(d)
            })
        })

        req.on('error', error => {
            console.error(error)
        })

        req.write(data)
        req.end()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM