title: How can I send a curl request from javascript?
body: <p>I would like to send this</p>
  
  <pre><code>curl https://fcm.googleapis.com/fcm/send \
       -H "Content-Type: application/json" \
       -H "Authorization: key=&lt;MY API KEY&gt;" \
       -d '{ "notification": {"title": "Hello world", "body": "you got a new message", "icon": "icon/path","click_action" : "page/path"},"to" : "&lt;DEVICE TOKEN&gt;"}'
  </code></pre>
  
  <p>from a js file to wherever I want. Considering the ideas you are giving me bellow, now I'm trying with this:</p>
  
  <pre><code>        $.ajax({
              url: "https://fcm.googleapis.com/fcm/send",
              type: 'POST',
              dataType: 'json',
              headers: {
                  'Access-Control-Allow-Origin' : '*',
                  'Authorization': '&lt;APY KEY&gt;',
                  'contentType': 'application/json',
              },
              data: {
                  'title': 'Hello world!', 
                  'body': 'you got a new message', 
                  'icon': 'icon/path', 
                  'click_action' : 'page/path', 
                  'to' : '&lt;DEVICE TOKEN&gt;',
              },
              success: function (result) {
                alert(JSON.stringify(data));
              },
              error: function (error) {
                 alert("Cannot get data");
              }
          });
  </code></pre>
  
  <p>but I'm getting this error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present</p>