Post request to 3rd party API

Hello, I am needing to make a post request to a 3rd party api. The example below is using a node library. I need to convert it to Wix Code module, any help with this would be greatly appreciated. I understand that the post data should come from a form from my page code. Also, I need the response from the post request to be placed in a database. The require portion is node, but I do not need. I think I need to create a export function? that is call from my page code?

const request = require(‘request’);
const url = ‘https://api.housecanary.com/v2/property/value’;
const postData = [ {‘address’: ‘43 Valmonte Plaza’, ‘zipcode’: ‘90274’}, {‘address’: ‘7500 Melrose Ave’, ‘zipcode’: ‘90046’} ];

request.post({ url: url, auth: { user: ‘my_api_key’, pass: ‘my_api_secret’ },

body: postData, json: true }, function (error, response, body) { console.log(body); });

2 Likes