-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Description
I am also experiencing issues using 1.5.2.
Description
API calls using 1.5.2 fail with "Response is not defined". In my case, this is true whether using API version "v1.0" or "beta". Here are the calls I am making and the (same) resultant error that is produced after each.
const { Client } = require('@microsoft/microsoft-graph-client');
class SimpleGraphClient {
constructor(token) {
if (!token || !token.trim()) {
throw new Error('SimpleGraphClient: Invalid token received.');
}
this._token = token;
// Get an Authenticated Microsoft Graph client using the token issued to the user.
this.graphClient = Client.init({
authProvider: (done) => {
done(null, this._token); // First parameter takes an error if you can't get an access token.
}
});
}
async sendMail(toAddress, subject, content) {
if (!toAddress || !toAddress.trim()) {
throw new Error('SimpleGraphClient.sendMail(): Invalid `toAddress` parameter received.');
}
if (!subject || !subject.trim()) {
throw new Error('SimpleGraphClient.sendMail(): Invalid `subject` parameter received.');
}
if (!content || !content.trim()) {
throw new Error('SimpleGraphClient.sendMail(): Invalid `content` parameter received.');
}
const mail = {
body: {
content: content, // `Hi there! I had this message sent via MS Graph. - Your friend, ${ graphData.displayName }!`,
contentType: 'Text'
},
subject: subject, // `Message from MS Graph!`,
toRecipients: [{
emailAddress: {
address: toAddress
}
}]
};
return await this.graphClient
.api('/me/sendMail')
.post({ message: mail }, (error, res) => {
if (error) {
throw error;
} else {
return res;
}
});
}
async getRecentMail() {
return await this.graphClient
.api('/me/messages')
.version('v1.0')
.top(5)
.get()
.then((res) => {
return res;
})
.catch((err) => {
console.log(err);
});
}
async getMe() {
return await this.graphClient
.api('/me')
.version('v1.0')
.get()
.then((res) => {
console.log(res);
return res;
})
.catch((err) => {
console.log(err);
});
}
async getManager() {
return await this.graphClient
.api('/me/manager')
.version('v1.0')
.select('displayName')
.get()
.then((res) => {
return res;
})
.catch((err) => {
console.log(err);
});
}
async getPhoto() {
return await this.graphClient
.api('/me/photo/$value')
.responseType('ArrayBuffer')
.version('v1.0')
.get()
.then((res) => {
return res;
})
.catch((err) => {
console.log(err);
});
}
}Downgrading to 1.4.0 and the API calls succeed.
Console Errors:
ReferenceError: Response is not defined
at Function.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:127:48)
at step (C:\...\node_modules\tslib\tslib.js:133:27)
at Object.next (C:\...\node_modules\tslib\tslib.js:114:57)
at C:\...\node_modules\tslib\tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (C:\...\node_modules\tslib\tslib.js:103:16)
at Function.GraphErrorHandler.getError (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:122:24)
at GraphRequest.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphRequest.js:227:84)
at step (C:\...\node_modules\tslib\tslib.js:133:27)
at Object.throw (C:\...\node_modules\tslib\tslib.js:114:57)
Steps to Reproduce
- Install NPM package v1.5.2
- Make the API calls
- Observe the errors
Expected behavior:
Values should be returned via MS Graph for the various API calls.
Actual behavior:
Receive "Response is not defined" error.
Originally posted by @stevkan in #151 (comment)
Metadata
Metadata
Assignees
Labels
No labels