Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { logMessage } from "https://esm.town/v/willthereader/logMessage";
// Immediately invoked function that exports a function generating a URL as a string,
// which fetches all comments from an article associated with the provided post_id.
export const constructReadTangleUrl = (() => {
return (post_id) => {
// logMessage( "debug", `constructReadTangleUrl called with post_id: ${post_id}`, );
const baseUrl = new URL("https://www.readtangle.com/members/api/comments/?filter=post_id%3A");
let commentUrl = "";
if (typeof post_id === "string") {
commentUrl = `${baseUrl}${post_id}`;
} else {
logMessage("Warning: post_id should be a string");
}
// logMessage("debug", `constructReadTangleUrl returning with URL: ${url.toString()}`);
return commentUrl;
};
})();
January 11, 2024