: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
import apiFetch from '@wordpress/api-fetch';
import PropTypes from 'prop-types';
* There is a straitforward way of sending all requests at once and have the Jobs in the loop done quicker
* BUT I fear it could result in memory exhaustion in some browsers, this way we run request by request
* TODO organize batches depending on the total amount of emails to be sent in order to make the process faster
export const sendEmail = async ( props, submissionID ) => {
'ninja-forms-submissions/email-action',
submission: submissionID,
action_settings: props.action,
parse: false, //Use false to manage errors, by default apiFetch is set to true on Parse and directly sends back the json response
//Count Processed emails (sent or not )
props.setEmailProcessed();
//Catch not OK fetch task or process response via json
//Push Submission ID in an array to store failures
console.log(response.json());
props.setNotSent( response.json() );
//Count Sent emails if sent or push Submission ID to an array if email was not sent
restUrl: PropTypes.string.isRequired,
action: PropTypes.object.isRequired,
formID: PropTypes.number.isRequired,
setSent: PropTypes.func.isRequired,
setNotSent: PropTypes.func.isRequired,
setEmailProcessed: PropTypes.func.isRequired,
signal: PropTypes.object.isRequired