[Question] Iterating on Array in Configured API Request #16
Replies: 10 comments 10 replies
-
Hey @julroger2013! The short answer to your question is: You can't. If it's not too forward I would like to know why not to use codeblocks? |
Beta Was this translation helpful? Give feedback.
-
Good question. Maybe you can help me figure out how to achieve the desired result I have in mind, whether that uses codeblocks or configured API requests. I manage my tasks with Todoist, which has a pretty well-established REST API. What I'm wanting to do is pull a list of tasks from Todoist in markdown format using the API. Each task is a JSON object with many components, such as priority, due date, UID, task name. I'd like to pull tasks using a filter function built into the API, and then extract only the task names from the returned JSON objects. I would want to format these as a markdown checklist, e.g. ...
And so on. That list then goes through a script (which I already have set up through Templater) which pairs the tasks against each other head-to-head (i.e. 1 v. 2, 1 v. 3, 2 v. 3, etc.) to prioritize. The task that ends up with the most head-to-head victories ends up first priority, second most as second priority, and so on. Basically, I'm just trying to use your plugin to manage the first part of this workflow - extracting the tasks from Todoist's API and putting them into a markdown checklist that can be processed by the script that I've already established. I figured I could use the "Paste Result" command from your plugin to produce that list in one step. Does that make sense? I'm open-minded about how best to approach this problem. I'm trying to get as close as I can to a single button-press to extract tasks, format them in a markdown checklist, and run them through the prioritization process. Thank you! |
Beta Was this translation helpful? Give feedback.
-
I think I'll have to change or add a couple of things on the plugin for this to work the way you need to. When I find a solution I'll write you. |
Beta Was this translation helpful? Give feedback.
-
I found a 'easy' way of doing this:
Do you think that would work with your workflow? |
Beta Was this translation helpful? Give feedback.
-
The format is pretty much right. The one downside is that it's not possible to drag-select the checkboxes, too, for copy-paste purposes. That's why I hoped to instead format things in a configured request and paste them with a command. As I'm sitting here thinking about it, though ... Templater can run JavaScript - is there any reason I can't just do an API request as part of a Templater script and then use other JavaScript functions as part of that script to format the returned values? Thanks for thinking this over! |
Beta Was this translation helpful? Give feedback.
-
One possibility - would it be hard to add a "copy contents" button to the top right corner of your code blocks? They have those in ordinary code blocks & also optionally in callouts, so you can copy the contents of the block. That might work well, and maybe would be easier than the configured portion of your plugin? Thanks again! |
Beta Was this translation helpful? Give feedback.
-
I believe you could do that. Don't know if it works tho.
I did that. Would be live in the next update.
|
Beta Was this translation helpful? Give feedback.
-
Great, thank you! A marginal idea, since the main benefit will already come from the copy contents function, but do you suppose your code blocks could be made to render markdown? The Better Search Views plugin probably has useful code when it comes to markdown rendering. It makes markdown render in, eg, backlinks views. Thanks again for adding the copy contents button! That will get me where I need to go. Have a great day. |
Beta Was this translation helpful? Give feedback.
-
Awesome, thank you. Really great plugin - I appreciate all the time you’ve spent making it!Again, I suspect that Better Search Views would contain some code relevant to markdown rendering.You’re the best.On May 7, 2024, at 11:08, Ronald Cantillo ***@***.***> wrote:
I don't know how hard it'll be but I'll try to implement it. 😉
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
This is great. It's working really, really well. If it's worth your time, I could see it being very useful having an API for your plugin. It's not really necessary for my purposes - the copy/paste into my Templater Script is plenty easy to do. But I can imagine some of the more JavaScript-savvy Obsidian users would love being able to directly plug the results of one of your API requests into something like Templater, where the result of the API request is just pulled as an input that can then be used within a larger script. Thanks so much for all you have done! This plugin is really amazing. |
Beta Was this translation helpful? Give feedback.
-
I had a question about the configured API requests.
I have a codeblock formatted as so:
Todoist returns an array of JSON objects, with each object representing a task, with various components such as id, content, priority, and so on.
This codeblock works perfectly in extracting the "content" component of each JSON object in the array - functionally, it's grabbing the name of each task that Todoist sends back.
I'm finding that I cannot figure out how to obtain the same results with the preconfigured API requests that you can set up in the plugin settings.
I would imagine that limiting to something like "content" - one component of each object in an array of objects - is done with the "What to display" box in the plugin settings, but I can't seem to figure out exactly how to set up the preconfigured API requests to obtain the same result as the codeblock above.
Any ideas on how I need to structure this configured request to obtain the desired result?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions