What's wrong with this fetch request?









up vote
-1
down vote

favorite












 let path=`api.openweathermap.org/data/2.5/weather?q=London`;
let apiKey= `&APPID=758bab291826491e79f93979de2ba255`
let url= path+apiKey;


function getWeather(url)
return fetch(url)
.then(response=> response.json())
.then(data=>console.log(data))
.catch(err=> console.log(err))



getWeather();


im getting this in the console



enter image description here
I cant figure it out, i'm very new to this. Its saying 404 but if I copy the URL and go to it it shows the JSON data



err after adding https://
enter image description here










share|improve this question



























    up vote
    -1
    down vote

    favorite












     let path=`api.openweathermap.org/data/2.5/weather?q=London`;
    let apiKey= `&APPID=758bab291826491e79f93979de2ba255`
    let url= path+apiKey;


    function getWeather(url)
    return fetch(url)
    .then(response=> response.json())
    .then(data=>console.log(data))
    .catch(err=> console.log(err))



    getWeather();


    im getting this in the console



    enter image description here
    I cant figure it out, i'm very new to this. Its saying 404 but if I copy the URL and go to it it shows the JSON data



    err after adding https://
    enter image description here










    share|improve this question

























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











       let path=`api.openweathermap.org/data/2.5/weather?q=London`;
      let apiKey= `&APPID=758bab291826491e79f93979de2ba255`
      let url= path+apiKey;


      function getWeather(url)
      return fetch(url)
      .then(response=> response.json())
      .then(data=>console.log(data))
      .catch(err=> console.log(err))



      getWeather();


      im getting this in the console



      enter image description here
      I cant figure it out, i'm very new to this. Its saying 404 but if I copy the URL and go to it it shows the JSON data



      err after adding https://
      enter image description here










      share|improve this question















       let path=`api.openweathermap.org/data/2.5/weather?q=London`;
      let apiKey= `&APPID=758bab291826491e79f93979de2ba255`
      let url= path+apiKey;


      function getWeather(url)
      return fetch(url)
      .then(response=> response.json())
      .then(data=>console.log(data))
      .catch(err=> console.log(err))



      getWeather();


      im getting this in the console



      enter image description here
      I cant figure it out, i'm very new to this. Its saying 404 but if I copy the URL and go to it it shows the JSON data



      err after adding https://
      enter image description here







      ajax fetch






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 20:26

























      asked Nov 8 at 19:14







      user10278089





























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          this should do the trick:



          let path = `https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey = `&APPID=758bab291826491e79f93979de2ba255`;
          let targetURL = path + apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response => response.json())
          .then(data => console.log(data))
          .catch(err => console.log(err));


          getWeather(targetURL);


          so there are 2 problems with your initial question:



          1. when you do a fetch it tries to do the fetch from the domain the the
            app is currently in. Which is why you're getting 127.0.0.1:5000
            (localhost), if you supply https:// it should not do that.

          2. you were not passing in the url to the getWeather(url) function that
            you had declared. Hope this helps!





          share|improve this answer






















          • Thanks so much, would you mind explaining where i went wrong?
            – user10278089
            Nov 8 at 20:35










          • i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
            – Matt Pengelly
            Nov 8 at 20:37






          • 1




            ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
            – Matt Pengelly
            Nov 8 at 20:39






          • 1




            the new edit is very close to what you originally had except with the 2 small fixes needed!
            – Matt Pengelly
            Nov 8 at 20:41

















          up vote
          0
          down vote













          try this instead:



          let path=`https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey=`&APPID=758bab291826491e79f93979de2ba255`
          let url=path+apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response=> response.json())
          .then(data=>console.log(data))
          .catch(err=> console.log(err))


          getWeather();


          This should work. why? Because when you do a fetch it tries to do the fetch from the domain the the app is currently in. Which is why you're getting 127.0.0.1:5000 (localhost), if you supply https:// it should not do that.






          share|improve this answer




















          • Still isnt working
            – user10278089
            Nov 8 at 20:16










          • what does the GET in the console show now for the url?
            – Matt Pengelly
            Nov 8 at 20:17











          • added photo to post
            – user10278089
            Nov 8 at 20:26










          • sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
            – Matt Pengelly
            Nov 8 at 20:33










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214658%2fwhats-wrong-with-this-fetch-request%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown
























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          this should do the trick:



          let path = `https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey = `&APPID=758bab291826491e79f93979de2ba255`;
          let targetURL = path + apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response => response.json())
          .then(data => console.log(data))
          .catch(err => console.log(err));


          getWeather(targetURL);


          so there are 2 problems with your initial question:



          1. when you do a fetch it tries to do the fetch from the domain the the
            app is currently in. Which is why you're getting 127.0.0.1:5000
            (localhost), if you supply https:// it should not do that.

          2. you were not passing in the url to the getWeather(url) function that
            you had declared. Hope this helps!





          share|improve this answer






















          • Thanks so much, would you mind explaining where i went wrong?
            – user10278089
            Nov 8 at 20:35










          • i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
            – Matt Pengelly
            Nov 8 at 20:37






          • 1




            ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
            – Matt Pengelly
            Nov 8 at 20:39






          • 1




            the new edit is very close to what you originally had except with the 2 small fixes needed!
            – Matt Pengelly
            Nov 8 at 20:41














          up vote
          0
          down vote



          accepted










          this should do the trick:



          let path = `https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey = `&APPID=758bab291826491e79f93979de2ba255`;
          let targetURL = path + apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response => response.json())
          .then(data => console.log(data))
          .catch(err => console.log(err));


          getWeather(targetURL);


          so there are 2 problems with your initial question:



          1. when you do a fetch it tries to do the fetch from the domain the the
            app is currently in. Which is why you're getting 127.0.0.1:5000
            (localhost), if you supply https:// it should not do that.

          2. you were not passing in the url to the getWeather(url) function that
            you had declared. Hope this helps!





          share|improve this answer






















          • Thanks so much, would you mind explaining where i went wrong?
            – user10278089
            Nov 8 at 20:35










          • i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
            – Matt Pengelly
            Nov 8 at 20:37






          • 1




            ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
            – Matt Pengelly
            Nov 8 at 20:39






          • 1




            the new edit is very close to what you originally had except with the 2 small fixes needed!
            – Matt Pengelly
            Nov 8 at 20:41












          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          this should do the trick:



          let path = `https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey = `&APPID=758bab291826491e79f93979de2ba255`;
          let targetURL = path + apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response => response.json())
          .then(data => console.log(data))
          .catch(err => console.log(err));


          getWeather(targetURL);


          so there are 2 problems with your initial question:



          1. when you do a fetch it tries to do the fetch from the domain the the
            app is currently in. Which is why you're getting 127.0.0.1:5000
            (localhost), if you supply https:// it should not do that.

          2. you were not passing in the url to the getWeather(url) function that
            you had declared. Hope this helps!





          share|improve this answer














          this should do the trick:



          let path = `https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey = `&APPID=758bab291826491e79f93979de2ba255`;
          let targetURL = path + apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response => response.json())
          .then(data => console.log(data))
          .catch(err => console.log(err));


          getWeather(targetURL);


          so there are 2 problems with your initial question:



          1. when you do a fetch it tries to do the fetch from the domain the the
            app is currently in. Which is why you're getting 127.0.0.1:5000
            (localhost), if you supply https:// it should not do that.

          2. you were not passing in the url to the getWeather(url) function that
            you had declared. Hope this helps!






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 8 at 20:42

























          answered Nov 8 at 20:33









          Matt Pengelly

          458316




          458316











          • Thanks so much, would you mind explaining where i went wrong?
            – user10278089
            Nov 8 at 20:35










          • i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
            – Matt Pengelly
            Nov 8 at 20:37






          • 1




            ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
            – Matt Pengelly
            Nov 8 at 20:39






          • 1




            the new edit is very close to what you originally had except with the 2 small fixes needed!
            – Matt Pengelly
            Nov 8 at 20:41
















          • Thanks so much, would you mind explaining where i went wrong?
            – user10278089
            Nov 8 at 20:35










          • i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
            – Matt Pengelly
            Nov 8 at 20:37






          • 1




            ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
            – Matt Pengelly
            Nov 8 at 20:39






          • 1




            the new edit is very close to what you originally had except with the 2 small fixes needed!
            – Matt Pengelly
            Nov 8 at 20:41















          Thanks so much, would you mind explaining where i went wrong?
          – user10278089
          Nov 8 at 20:35




          Thanks so much, would you mind explaining where i went wrong?
          – user10278089
          Nov 8 at 20:35












          i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
          – Matt Pengelly
          Nov 8 at 20:37




          i edited the answer above. There were 2 issues :). you can still do the path + url like you had before as well. that wasnt part of the issue.
          – Matt Pengelly
          Nov 8 at 20:37




          1




          1




          ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
          – Matt Pengelly
          Nov 8 at 20:39




          ill edit the answer again so that it reflect more what you had originally wwrote. i simply had simplified the original problem to make understanding the problem easier for myself. just a minute and you should see a new edit.
          – Matt Pengelly
          Nov 8 at 20:39




          1




          1




          the new edit is very close to what you originally had except with the 2 small fixes needed!
          – Matt Pengelly
          Nov 8 at 20:41




          the new edit is very close to what you originally had except with the 2 small fixes needed!
          – Matt Pengelly
          Nov 8 at 20:41












          up vote
          0
          down vote













          try this instead:



          let path=`https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey=`&APPID=758bab291826491e79f93979de2ba255`
          let url=path+apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response=> response.json())
          .then(data=>console.log(data))
          .catch(err=> console.log(err))


          getWeather();


          This should work. why? Because when you do a fetch it tries to do the fetch from the domain the the app is currently in. Which is why you're getting 127.0.0.1:5000 (localhost), if you supply https:// it should not do that.






          share|improve this answer




















          • Still isnt working
            – user10278089
            Nov 8 at 20:16










          • what does the GET in the console show now for the url?
            – Matt Pengelly
            Nov 8 at 20:17











          • added photo to post
            – user10278089
            Nov 8 at 20:26










          • sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
            – Matt Pengelly
            Nov 8 at 20:33














          up vote
          0
          down vote













          try this instead:



          let path=`https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey=`&APPID=758bab291826491e79f93979de2ba255`
          let url=path+apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response=> response.json())
          .then(data=>console.log(data))
          .catch(err=> console.log(err))


          getWeather();


          This should work. why? Because when you do a fetch it tries to do the fetch from the domain the the app is currently in. Which is why you're getting 127.0.0.1:5000 (localhost), if you supply https:// it should not do that.






          share|improve this answer




















          • Still isnt working
            – user10278089
            Nov 8 at 20:16










          • what does the GET in the console show now for the url?
            – Matt Pengelly
            Nov 8 at 20:17











          • added photo to post
            – user10278089
            Nov 8 at 20:26










          • sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
            – Matt Pengelly
            Nov 8 at 20:33












          up vote
          0
          down vote










          up vote
          0
          down vote









          try this instead:



          let path=`https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey=`&APPID=758bab291826491e79f93979de2ba255`
          let url=path+apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response=> response.json())
          .then(data=>console.log(data))
          .catch(err=> console.log(err))


          getWeather();


          This should work. why? Because when you do a fetch it tries to do the fetch from the domain the the app is currently in. Which is why you're getting 127.0.0.1:5000 (localhost), if you supply https:// it should not do that.






          share|improve this answer












          try this instead:



          let path=`https://api.openweathermap.org/data/2.5/weather?q=London`;
          let apiKey=`&APPID=758bab291826491e79f93979de2ba255`
          let url=path+apiKey;

          function getWeather(url)
          return fetch(url)
          .then(response=> response.json())
          .then(data=>console.log(data))
          .catch(err=> console.log(err))


          getWeather();


          This should work. why? Because when you do a fetch it tries to do the fetch from the domain the the app is currently in. Which is why you're getting 127.0.0.1:5000 (localhost), if you supply https:// it should not do that.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 20:00









          Matt Pengelly

          458316




          458316











          • Still isnt working
            – user10278089
            Nov 8 at 20:16










          • what does the GET in the console show now for the url?
            – Matt Pengelly
            Nov 8 at 20:17











          • added photo to post
            – user10278089
            Nov 8 at 20:26










          • sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
            – Matt Pengelly
            Nov 8 at 20:33
















          • Still isnt working
            – user10278089
            Nov 8 at 20:16










          • what does the GET in the console show now for the url?
            – Matt Pengelly
            Nov 8 at 20:17











          • added photo to post
            – user10278089
            Nov 8 at 20:26










          • sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
            – Matt Pengelly
            Nov 8 at 20:33















          Still isnt working
          – user10278089
          Nov 8 at 20:16




          Still isnt working
          – user10278089
          Nov 8 at 20:16












          what does the GET in the console show now for the url?
          – Matt Pengelly
          Nov 8 at 20:17





          what does the GET in the console show now for the url?
          – Matt Pengelly
          Nov 8 at 20:17













          added photo to post
          – user10278089
          Nov 8 at 20:26




          added photo to post
          – user10278089
          Nov 8 at 20:26












          sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
          – Matt Pengelly
          Nov 8 at 20:33




          sorry about that i submitted a different answer and it works in my browser now. so that other answer should work for you.
          – Matt Pengelly
          Nov 8 at 20:33

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214658%2fwhats-wrong-with-this-fetch-request%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Crossroads (UK TV series)

          ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế