Home > Back-end >  How to do a get request with parameters [NODE.JS]
How to do a get request with parameters [NODE.JS]

Time:01-27

Thank you for reading. It has litteraly been hours that i've been searching for my problem: as said in the title didn't found anything even looked at docs of nodejs but there isn't what i'm searching so it's weird seems like no one does that?

const https = require("https")

https.request("http://aratools.com/dict-service?query={"dictionary":"AR-EN-WORD-DICTIONARY","word":"نعم","dfilter":true}&format=json&_=1643219263345",
    (res) => {
        console.log(res)
    }
)

the error: enter image description here

website used: http://aratools.com/ Trying to do experiment thing later on (have something in head but first have to manage to do this get request)

CodePudding user response:

Try to use the http module instead of https.

    const http = require("http")
    
    http.request("http://aratools.com/dict-service?query={"dictionary":"AR-EN-WORD-DICTIONARY","word":"نعم","dfilter":true}&format=json&_=1643219263345",
        (res) => {
            console.log(res)
        }
    )

CodePudding user response:

You need to specify https in the URL and not http if you're using the package https. Otherwise you should use the package http.

  •  Tags:  
  • Related