Its don’t working. I need send data (after click to cart button - its can be any button) to analytic server.
How I can fix it?
// Sorry can’t add it like code, because its some error with URLs
Its don’t working. I need send data (after click to cart button - its can be any button) to analytic server.
How I can fix it?
// Sorry can’t add it like code, because its some error with URLs
Is it possible?
Corvid understands all of Javascript, except for anything that accesses the DOM. Accessing document elements such as window, div, span, button, etc is off-limits. The way to access elements on the page is only through $w.
See the article Corvid: JavaScript Support .
The alert() function is also not supported.
XMLHttpRequest is not supported. You might want to use the NPM library available via the Wix Package Manager :
You might also be able to use the wix-fetch API to access your external URLs. Read the article Accessing 3rd Party Services for more information on accessing external web services. The article Calling Server-side Code from the Front-end with Web Modules might also be useful depending on your use case.
Hello Yisrael !
Thank you so much for your answer))
Its seems like what I need (I think):
but how I can send Product info?
like user choose some my product and after click to button product info need to send to server.
I’m always get error in last example…((
exportfunctionbuttonFetchRate_click(event) { let url = "https://api .exchangeratesapi.io/latest?base=USD"; let symbol = $w("#textInputSymbol").value; let fullUrl = url + "&symbols=" + symbol; fetch(fullUrl, {method: 'get'}) .then(response => response.json()) .then(json => $w("#textRate").text = json.rates[symbol].toString()); }
or
import {fetch} from 'wix-fetch';
export function button1_onClick(event, $w) {
$w('#productPage1').getProduct()
.then( (product) => {
fetch('https: // slav. city/ boo2.php', {method: 'post'})
.then( (httpResponse) => {
if (httpResponse.ok) {
alert('Thanks for buy!');
} else {
return Promise.reject("Fetch did not succeed"); }
} )
.catch(err => console.log(err));
}
}
@logopedd85 Third party APIs are not part of the Corvid product and we cannot provide support. You should reach out to the service provider to find out what is needed in order to interface with their API. The documentation on the wix-fetch API and the article Accessing 3rd Party Services will provide you with details on how to access external services.
@yisrael-wix Thank you for your answer)))