Code Monkey home page Code Monkey logo

Comments (6)

kfranqueiro avatar kfranqueiro commented on August 28, 2024

I just looked at request/node's code a bit, and I don't think it supports data as an object. The tests seem to indicate it can accept one of core's ReadableStreams or a string, though it's not clear to me from request/node's code how a string would work either, since it just immediately calls request.end.

At the very least I'd say try serializing that object to a x-www-form-urlencoded string yourself and see if that works. (core's UrlSearchParams or node's querystring can help with that.)

If this makes it inconsistent with the xhr provider then it's probably something we should look at...

from core.

odoe avatar odoe commented on August 28, 2024

Ah, ok.

So this works then.

var params = new UrlSearchParams(DATA);
var paramsString = params.toString();
// using dojo-core/request
function getDojoToken(callback){
  dojoRequest.post('https://www.arcgis.com/sharing/rest/oauth2/token/',{
    responseType: 'json',
    query: paramsString
  }).then(function(results) {
    console.log('dojo request results', results.data);
  });
}

I suppose I can do a has('host-node') check around a function to create the parameters so this can be used in multiple environments.

Thanks for clearing that up!

from core.

vansimke avatar vansimke commented on August 28, 2024

I think that @kfranqueiro is correct. Strings aren't handled properly as the 'data' field. That test is looking at the response data, not the data received by the server. I'll fix that, but supporting object literals is not currently supported and I can't find evidence that this is planned since it can be accomplished via JSON.stringify(DATA).

from core.

kfranqueiro avatar kfranqueiro commented on August 28, 2024

I don't know/remember off the top of my head, but I suspect it might be intentional, given that people have different opinions/requirements as to whether their objects should be serialized simply as JSON, or as www-form-urlencoded strings.

from core.

kitsonk avatar kitsonk commented on August 28, 2024

I think the intention would be that they would use the filterRegistry to deal with whatever needs they have specifically for post processing of requests.

from core.

vansimke avatar vansimke commented on August 28, 2024

Issued PR #127 to correct issue where options.data not being sent to server when it contained a non-stream.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.