graphClient.Directory.AdministrativeUnits - azure

I am trying to get AdministrativeUnits using the Microsoft.Graph.Api, but when I write the following lines I get error on Directory.AdministrativeUnits
var administrativeUnits = await graphClient.Directory.AdministrativeUnits.Request().GetAsync();
The graphClient.Directory doesnt have AdministrativeUnits what am I missing?
from here:
https://learn.microsoft.com/en-us/graph/api/administrativeunit-list?view=graph-rest-1.0&tabs=csharp

Related

Node unable to find local module

I was testing a very simple module to see if it works and keep on getting an error stating that node cannot find my module.
//mymodule.js
greeting = 'hello'
module.exports = greeting;
// main.js
const s = require('exportsPractice\mymodule.js');
console.log(s);
The error I get is shown here
Try using:
const s = require('./exportsPractice/mymodule.js');
And make sure the path is correct.

Reference error! Not defined using node.js / Runkit

I'm trying to use this https://npm.runkit.com/globalpayments-api script but I can't figure what I'm doing wrong.
When I run the Runkit and add the first code to create a new Credit Card it throws error "ReferenceError: CreditCardData is not defined":
const card = new CreditCardData();
card.number = "4111111111111111";
card.expMonth = "12";
card.expYear = "2025";
card.cvn = "123";
How I can point CreditCardData to var globalpaymentsApi = require("globalpayments-api") which contains all this consts?
Demo: https://runkit.com/embed/8hidbubpbk8n
What I'm doing wrong?
Most likely in your code, function CreditCardData() doesn't exist - this means you didn't import it. Try adding this at the beginning of your .js file:
const { CreditCardData } = require('globalpayments-api');

module.exports variable producing undefined result

So one of the features of the bot I am working on is that I can be on discord 'discreetly', meaning that I can have the idle status but if a friend knows what command to call, they can actually check if I am there. So in my index file I am using module.exports to store the variable that will contain the info that I set. In the other file, I have an array of values that depending on the value from the variable, the bot will respond with one of the phrases from the array. The problem is that when using the variable, I get an undefined response. Any ideas what I am doing wrong? Important to note
I have checked to make sure by putting an actual number and have gotten the correct response so it is an issue with the exporting. I also have the correct file path. I have also assigned variable info a number and gotten the same result. Edit: tried using the filepath as part of the variable in the array like so and got the same error
//This got me a new result so progress.
const filepath = filepath;
console.log(filepath); //This gets me {}
message.reply(activity[info]); //undefined
//new attempt that failed
//paraphrasing the filepath assignment
const filepath = filepath;
activity[filepath.info]
//first attempt
//from index
var info = message.content;
module.exports = info;
//from the other file
var activity = ["Ready to play","Chilling","Doing work","afk","can talk"];
console.log(activity[info]);
message.reply(activity[info]);
how to get a variable from a file to another file in node.js
So this is the solution to my problem
//index
var info = message.content;
module.exports.info = message.content;
//other file
const filepath = filepath;
var activity = [array of different values];
message.reply(activity[index.info]);
Thank you slothiful for you time in trying to help me. I really appreciate it

Logging variable in nodejs

I have a variable named, 'res'. This variable if used with console.log() print all request to a function. My question is... How to log this variable in a log.txt file?
Example using console.log(res)
Print in console:
[ 'AndroidShareANE',
'pixi.js',
'ShortSword',
'faceshiftparser',
'clmutils',
'chaikin-smooth',
'getuservideo',
'getboundingbox',
'clmdraw',
'SpriteSheetScrubberTutorial',
'interpolation-arrays',
This is a one part of response.
My purpose is log in log.txt file the var content. Identical to console.log() result.
Thanks for your collaboration, and sorry my bad english.
The easiest way is to create a new Console object that writes to your file. The docs have an example of this exact thing, which I'll reproduce here for posterity:
const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
// custom simple logger
const logger = new Console(output, errorOutput);
// use it like console
var count = 5;
logger.log('count: %d', count);
// in stdout.log: count 5
If you don't pass the second argument (errorOutput) to new Console then the error output will also be written to the output file.

Strange Error in using consolelog in nodejs

Using node.js 0.10.24.
I got an error telling me that "Object has no method log" in 6th line in following code.
But when 3rd line enabled, no problem. Anyone know why?
var EE=require("events").EventEmitter;
var on=EE.prototype.on;
//var c=console;
EE.prototype.on=function(event,handler){
console.log("added "+event);
on.call(this,event,handler);
};
var server=require('http').createServer();

Resources