I previously posted this issue on stackoverflow, but I had simplified it so it could be easier to understand and answer : this was a really bad move as I got totally inadequate answers.
I'm trying to program a Discord Javascript bot using NodeJS. The purpose of this bot is to fetch content from DeviantArt, using their OAuth2 client_id/client_secret authentification method.
My problem is that once the jQuery request is sent, it never goes back and the callback function is never called : so I cannot know what failed because the "status" var stays blank.
var jsdom = require("jsdom").jsdom;
var doc = jsdom();
var window = doc.defaultView;
var $ = require('jquery')(window);
var jsonFinal = '';
var token_url = 'https://www.deviantart.com/oauth2/token';
$.get( token_url, { grant_type: 'client_credentials', client_id: 5946, client_secret: 'whatever'} ).done(function( data ) {
jsonFinal = "("+data.status+data.error+")\n"+data;
console.log(jsonFinal);
});
(I'm using jsdom and jquery on nodeJS 6)
I followed the DA API documentation and I'm pretty sure that these are the right values to send to their server and that this is the right way to send them.
However, the console.log() in this code is never triggered.
How ? Why ?
Your problem is probably that you shouldn't put a function as an argument in your done function. But just in case there is some other problem try this:
var jsdom = require("jsdom").jsdom;
var doc = jsdom();
var window = doc.defaultView;
var $ = require('jquery')(window);
var jsonFinal = '';
var token_url = 'https://www.deviantart.com/oauth2/token';
$.get( token_url, {
grant_type: 'client_credentials',
client_id: 5946,
client_secret: 'whatever'
})
.done(function(data) {
console.log(data);
jsonFinal = "("+data.status+data.error+")\n"+data;
console.log(jsonFinal);
})
.fail(function(error) {
console.log(error);
})
.always(function() {
console.log("done");
});
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have spent a long time simply trying to install React and React-DOM
I started to develop a little web site in NodeJS, with admin authentication based on https://githubcom/DanialK/Simple-Authentication, it work very well
In nodejs we commonly do something like:
I am new to AWSI am creating a Scheduled lambda function using NodeJS