Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept GET/POST param for warpables json instead of a URL #32

Closed
jywarren opened this issue Dec 4, 2019 · 2 comments · Fixed by #33
Closed

Accept GET/POST param for warpables json instead of a URL #32

jywarren opened this issue Dec 4, 2019 · 2 comments · Fixed by #33

Comments

@jywarren
Copy link
Member

jywarren commented Dec 4, 2019

I want to move us closer to completing integration with MapKnitter, and we'll need this to be able to accept the JSON collection as follows:

$.post("http://34.74.118.242/api/v2/export/", {
    scale: 30,
    upload: true,
    collection: aJsonCollection // here is where we'll pass in the JSON
});

Just like in https://github.com/publiclab/mapknitter-exporter-sinatra#usage

Can we do that pretty easily, if URL isn't specified?

let url = req.query.url || req.body;
let scale = req.query.scale
console.log("Export endpoint hit for url " + url);
require("axios").get(url).then(function(data) {
res.redirect(req.protocol + '://' + req.get('host') + "/api/v2/process" + `/?upload=${req.query.upload}&scale=${scale}&steps=${JSON.stringify(require('./util/converter-multiSequencer')(data.data, parseFloat(scale)))}`);

Thanks!

@jywarren jywarren mentioned this issue Dec 4, 2019
5 tasks
@jywarren
Copy link
Member Author

jywarren commented Dec 4, 2019

Once we have this, we can show the above in the README as how to use this:

$.post("http://34.74.118.242/api/v2/export/", {
    scale: 30,
    upload: true,
    collection: aJsonCollection // here is where we'll pass in the JSON
}).success(function(response) {
  // here 'response' will include the URL to get status updates from
});

@jywarren
Copy link
Member Author

jywarren commented Dec 5, 2019

I created a PR here - do you think this'll work, @tech4GT ? #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant