title: Using JSONP to retrieve data from Twitter API
body: <p>I am trying to use jsonp to retrieve an embedded tweet (or several but let's start with 1) from the twitter api.  Cannot just use a get because of CORS, so I am trying jsonp, had it working just fine on a test page...</p>
  
  <p>This code works, and gets the embed code just fine, when run on a website.</p>
  
  <pre><code>function myJSCallback() {
              console.log('called back');
          }
  
  
          var urlx = 'https://api.twitter.com/1/statuses/oembed.json?url=https://twitter.com/louisck/status/1209181253444030468';
  
          $.ajax({
              url: urlx,
              type: 'GET',
              jsonpCallback: 'myJSCallback',
              dataType: 'jsonp',
              jsonp: 'callback',
              success: function (result) {
                  console.log(result.html);
              }
          });
  </code></pre>
  
  <p>However, if I run that exact code inside a chrome extension, I get an error.</p>
  
  <blockquote>
    <p>Uncaught (in promise) TypeError: Cannot assign to read only property
    'undefined' of object '#'</p>
  </blockquote>
  
  <p>If I run it without the callback, I get a different error...</p>
  
  <blockquote>
    <p>actual error :
    oembed.json?url=<a href="https://twitter.com/JackPosobiec/status/1238074823651274752&amp;callback=jQuery34101717550445740914_1584065740386&amp;_=1584065740387:1" rel="nofollow noreferrer">https://twitter.com/JackPosobiec/status/1238074823651274752&amp;callback=jQuery34101717550445740914_1584065740386&amp;_=1584065740387:1</a>
    Uncaught ReferenceError: jQuery34101717550445740914_1584065740386 is
    not defined</p>
  </blockquote>
  
  <p>Both versions work just fine when I run these in a regular website.  Neither work when I run them in a google chrome extension. I am trying to populate tweets on a page after it loads.  Just can't seem to figure this one out.</p>