How to add ajax url to js using wp_add_inline_script()?

If anyone still needs it:

wp_add_inline_script(
  'map-scripts',
  'const ajax_info = ' . json_encode(array(
      'ajaxurl' => admin_url('admin-ajax.php'),
   )),
  'before'
);

but, it’s good practice to use nonce as well for better security:

wp_add_inline_script(
  'map-scripts',
  'const ajax_info = ' . json_encode(array(
      'ajaxurl' => admin_url('admin-ajax.php'),
      'nonce' => wp_create_nonce('your_nonce_handler'), //the more specific the better
      'your_other_item' => "some additional data", //etc.. 
   )),
  'before'
);

https://developer.wordpress.org/reference/functions/wp_add_inline_script/

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)