siteStructure seems to be just front-end code - can you send an object like the page names to a 3rd party API? How?
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Hi Adam,
The api for wix-site can only be accessed by front end code, therefore you will need to implement a front end function to grab it and send it to the back end for further processing.
For example you could create an admin only page ( password protected) with a button to grab the site structure and store it in a collection for easy access further processing by your backend code.
Note that at the moment there is no option to create schedule function runs therefore you will need to click the button after each update to site structure.
You mentioned you want to allow external api to request the structure - for that you will need to implement wix http-functions as explained here
Or with client-side code that calls a server side function??
OK, so that is great but I am imagining you would put that client-side (or you have to put that client-side), right?
The APIs in wix-site can only be used in front-end code.
That is where I am confused. I would not want to send the site structure on page load, I would want to request it from a 3rd party.
Can you show an example of how to do this server-side?
Hi,
Below is an example on how to send the site structure as a json over to a third party API using a POST request.
import wixSite from 'wix-site'; import {fetch} from 'wix-fetch'; const thirdPartyApi = "https://someaddress.com/"; let siteStructure = wixSite.getSiteStructure(); let fetchOptions = { method: 'post',body: JSON.stringify(siteStructure) }; fetch(thirdPartyApi, fetchOptions) .then( (httpResponse) => { if (httpResponse.ok) { console.log("ok") } else { return Promise.reject("Fetch did not succeed"); } } ) .then(response => console.log(response)); .catch(err => console.log(err));