Using a variable in an api request header field

I’m working on the wikipedia viewer project and am having trouble trying to get the api to search the results from my form input. The “result” variable represents my input value from my index page.
The code seems to work fine if I hard code something into the search field in the request header. You’ll see the word “hello” there now. I’ve been trying to somehow use “result” in that field by using string concatination but the an error in the console that says “search must be set”. I’m not sure how to alter the header in such a way to fit that variable in there. Help will be appreciated.

$('#search').keypress(function () {
  let result = document.getElementById('search').value;
    url: '',
    dataType: 'jsonp',
    type: 'GET',
    success: function (data) {
        for (var i = 0; i < 10; i++) {
          $('.container').append('<div class="content">' + data[1][i] + '<br><br>' + data[2][i] + '</div>');

Just clarifying, but you did try
url: '" + result + "&prop=revisions&rvprop=content&formatversion=2' right?

I just tried it and it hard codes the word “result” unfortunately.

Sorry about that. I usually build it in an editor first. Totally forgot to transfer it to codepen and share the link.

Thanks for the info! It works great now! The help is very appreciated!