Hi Matt
Firstly, apologies for the delayed reply.
> I spent a lot of time messing around and searching the internet to try to
> learn how to make an http request.
That pretty much sums up what software developers do :)
> This is the what I've managed to come up with:
That’s pretty close. Try this (untested):
console.log('pleasework starting');
var http = require('http');
http.post = require('http-post');
var newTid = {
text: "Tiddler text",
title: "WillThisWork",
type: "text/vnd.tiddlywiki"
};
http.post('http://127.0.0.1:8080/recipes/default/tiddlers/WillThisWork',
JSON.stringify(newTid), function(res){
res.setEncoding('utf8');
res.on('data', function(chunk) {
console.log(chunk);
});
});
The general idea is to compose the tiddler as a JavaScript object, and then use
JSON.stringify() to convert it to a JSON string for sending over the network.
Best wishes
Jeremy
>
> console.log('pleasework starting');
>
> var http = require('http');
> http.post = require('http-post');
>
> var newTidText = '{' +
> '"text": "Tiddler text",' +
> '"title": "WillThisWork",' +
> '"type": "text/vnd.tiddlywiki"' +
> '}';
>
> //var newTid = JSON.parse(newTidText);
>
> http.post('http://127.0.0.1:8080/recipes/default/tiddlers/WillThisWork
> <http://127.0.0.1:8080/recipes/default/tiddlers/WillThisWork>', newTidText,
> function(res){
> res.setEncoding('utf8');
> res.on('data', function(chunk) {
> console.log(chunk);
> });
> });
>
> I commented out JSON.parse because I think it might not be necessary, but I'm
> not sure. I found a program to watch network traffic, but I can't seem to do
> anything that this program will respond to.
>
> So in terminal, I do:
>
> node pleasework.js
>
> And it gives the output:
>
> pleasework starting
>
> but still, I don't think anything is going through to my TiddlyWiki server.
> Meanwhile, whenever I do anything in my TiddlyWiki, the program picks it up
> and shows me all of the details. So I know exactly what I am looking for, but
> there must be something missing in my javascript code.
>
> What am I missing?
>
>
> On Friday, February 10, 2017 at 11:23:59 PM UTC-5, Matt Groth wrote:
> Hi,
>
> I'm a beginner at programming. I just set up m tiddlywiki with Node.JS. I'm
> having trouble figuring out how to use commands to control TiddlyWiki. Can
> someone point me to a "Hello World" step by step tutorial of how to make
> command for TiddlyWiki using Node.JS? Specifically I would like to commands
> to open and close tiddlers, but in general I am having a lot of trouble
> finding guides or APIs or anything.
>
> I also can't find any code to edit. Where is all the code that controls how
> Node.JS interacts with tiddlywiki? I've been searching my computer but can't
> find anything. My TiddlyWiki folder only has the .tid files and a .info file
> that doesn't seem too important.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/tiddlywiki
> <https://groups.google.com/group/tiddlywiki>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/dc5dd29d-a532-476d-a31c-0cfc074a1afe%40googlegroups.com
>
> <https://groups.google.com/d/msgid/tiddlywiki/dc5dd29d-a532-476d-a31c-0cfc074a1afe%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/5A37A187-C99E-461A-BDFD-85DDAD8ADBC4%40gmail.com.
For more options, visit https://groups.google.com/d/optout.