How can I get value of managed_file (form api) in javascript

I want to know how I can pass a variable in PHP to javascript or get the data in javascript.

I have a file upload (managed_file) in the buildForm.

$form['upload_file'] = array(
  '#type' => 'managed_file',
  '#upload_location' => $destination . 'channel' . '/' . $cid,
  '#attributes' => array('class' => array('ol_fileupload alert alert-default')),

And in the submitForm I have:

/* Fetch the array of the file stored temporarily in database */
$image = $form_state->getValue('upload_file');

/* Load the object of the file by it's fid */
$file = File::load($image[0]);
$getType = $file->getMimeType();
$getUrl = $file->getFileUri();

With that I get the correct values, but I want these variables in my javascript because I want to have a .change on it and send the data to node.js.

I’ve been struggling for hours, can someone help me?


Drupal version: