After several customers were unable to do basic month around delivery dates, I wanted to add a custom box that displays the current date + 8 days. At the moment the code calculates the new date correctly but won’t display when called within the text box. Instead, the developer page returns the following as an error:
Wix code SDK error: The text parameter that is passed to the text method cannot be set to the value Sun Jul 14 2019 19:22:16 GMT-0500 (Central Daylight Time). It must be of type string.
This calculation is correct, although I’ll have to rewrite it entirely to only include Day/Month/Year. However, the biggest issue is that regardless of what I write, it won’t populate #test2. I did a test run just populating today’s date in #test2, which worked. Suggestions for ways to display current date + 8 days?
import {getJSON} from ‘wix-fetch’;
const url = “https://api.exchangeratesapi.io/latest”;
$w.onReady( function () {
//TODO: write your page related code here…
Date.prototype.addDays = function (days) {
this .setDate( this .getDate() + parseInt(days));
return this ;
};
var newDate = new Date().addDays(8); //+8 days
console.log(newDate);
// Sets the property of test2 to newDate
$w(“#test2”).text = newDate;
});