Skip to content

Methods .getStream and .putStream don't support Promises #110

Closed

Description

When trying to use the "Promise" syntax of the .getStream method (ie. with no callback),

client.api(url).getStream()
	.then(stream => {
		// do something with stream
	})
	.catch(err => {
		// do domething with err
	})

I get the following error:

TypeError: Cannot read property 'then' of undefined

Nevertheless, the"callback" syntax works great:

return new Promise((resolve, reject) => {
	client.api(url).getStream((err, stream) => {
		if (err) {
			// do domething with err
		}
		else {
			// do something with stream
		}
	});
});

Activity

  1. jmorino commented on Sep 10, 2018

    @jmorino
    Author

    The same goes for the .putStream method:

    client.api(url).putStream(buffer)
        .then(response => {
            // do something with response
        })
    

    gives the following error:

    TypeError: callback is not a function
        at Function.ResponseHandler.init (/.../node_modules/@microsoft/microsoft-graph-client/src/ResponseHandler.ts:6:13)
        at /.../node_modules/@microsoft/microsoft-graph-client/src/GraphRequest.ts:291:33
        at process._tickCallback (internal/process/next_tick.js:68:7)
    
  2. changed the title [-]Method .getStream doesn't support Promises[/-] [+]Methods .getStream and .putStream doesn't support Promises[/+] on Sep 10, 2018
  3. changed the title [-]Methods .getStream and .putStream doesn't support Promises[/-] [+]Methods .getStream and .putStream don't support Promises[/+] on Sep 10, 2018
  4. muthurathinam commented on Sep 10, 2018

    @muthurathinam
    Contributor

    This is done in this pull request and will be available in our next release.

    876748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions