• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

axios request returns no data, while http request does

Scheduled Pinned Locked Moved General Discussion
7 Posts 5 Posters 2.6k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    A Former User
    last edited by Sep 12, 2020, 4:36 AM

    Hi,

    Sometime something like this with https can help:

    const httpsAgentConfig = { rejectUnauthorized: false }
    this.axiosInstance = axios.create({
      httpsAgent: new https.Agent(httpsAgentConfig),
    })
    

    after adapt it with your code
    try it, no guaranties… but maybe …

    1 Reply Last reply Reply Quote 0
    • A Offline
      ASh
      last edited by Oct 5, 2020, 6:01 AM

      Did you ever find out the answer to this, i’m having the same issue.

      1 Reply Last reply Reply Quote 0
      • L Offline
        lavolp3 Module Developer
        last edited by Oct 5, 2020, 9:23 AM

        No unfortunately not.
        Above addition did not help.

        I’m getting the feeling that the axios requests somehow closes before the data field is being returned. Haven’t tried much since it is not highest priority for me. But would appreciate any idea/suggestion.

        How to troubleshoot modules
        MMM-soccer v2, MMM-AVStock

        1 Reply Last reply Reply Quote 0
        • S Offline
          sharklaser
          last edited by Dec 31, 2020, 12:43 PM

          for some reason it doesn’t seem to like the axios user agent. Changing it to something else appears to work. Example:

          axios.defaults.headers.common['User-Agent'] = 'PostmanRuntime/7.26.2';
          
          S L 2 Replies Last reply Dec 31, 2020, 1:18 PM Reply Quote 1
          • S Offline
            sdetweil @sharklaser
            last edited by Dec 31, 2020, 1:18 PM

            @sharklaser many servers use the user-agent string to generate different content , as the ‘browsers’ all support different things, so a random string as user-agent will fail

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • L Offline
              lavolp3 Module Developer @sharklaser
              last edited by Jan 6, 2021, 10:35 PM

              @sharklaser said in axios request returns no data, while http request does:

              :
              axios.defaults.headers.common[‘User-Agent’] = ‘PostmanRuntime/7.26.2’;

              That was the solution! Thanks!!

              How to troubleshoot modules
              MMM-soccer v2, MMM-AVStock

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy