You are not logged in. Sign in or register.

#1 2019-06-08 22:46:57

ads2
Member
Registered: 2019-06-08
Posts: 2

node js

Can we have an example how to use this api. with node.js (axios)

Offline

#2 2019-06-08 22:53:29

dave
Developer
Registered: 2018-11-09
Posts: 161
Website

Re: node js

Hi ads2,

I can finish you an example of Node JS, but it will not be very different from the jQuery example.


Senior-Developer and System-Administrator. Don't fuck with a Hacker's machine!

Offline

#3 2019-06-08 22:59:56

ads2
Member
Registered: 2019-06-08
Posts: 2

Re: node js

hello Dave, i think this would be awesome. since javascript(node.js) is widly used stack. i think this will also help this awsome search engine to get more popular.

Last edited by ads2 (2019-06-08 23:00:22)

Offline

#4 2019-06-08 23:09:16

dave
Developer
Registered: 2018-11-09
Posts: 161
Website

Re: node js

Below you will find a very simple example, but in the near future I will deliver an elaborated example.

The request module makes this really easy. Install "request" into your package from npm, and then you can make a get request.

- npm install request
or if you want to install the request module for this project only type:
- npm install request --save

Thank you very much for your request.

var request = require("request")

let key = 'YOUR API KEY';
let name = 'YOUR NAME';
let query = 'YOUR KEYWORD';

let offset = 0;
let lang = 'en';
let format = 'json';

let url = 'https://api.qmeta.net/conn.php?key=' + key + '&query=' + query + '&offset=' + offset + '&lang=' + lang + '&format=' + format;

request({
    url: url,
    json: true
}, function (error, response, body) {

    if (!error && response.statusCode === 200) {
        console.log(body) // Print the json response
    }
})

Senior-Developer and System-Administrator. Don't fuck with a Hacker's machine!

Offline

#5 2019-06-09 00:43:35

dave
Developer
Registered: 2018-11-09
Posts: 161
Website

Re: node js

I have completed a more complex example. In this example a webserver is started under port 8000 to display the output in HTML.

You can find it here: https://forum.qmeta.net/viewtopic.php?id=112

Have fun!


Senior-Developer and System-Administrator. Don't fuck with a Hacker's machine!

Offline