301
1
302
1
Understanding Regex (ttrpg.network)

I am currently trying to learn Javascript and am getting hung up trying to understand Regex. Does anyone have any good resources or recommendations for me?

303
1
submitted 2 years ago* (last edited 2 years ago) by dres@lemmy.ca to c/javascript@programming.dev
304
1
305
1
306
1

Introducing Deno Queues - zero config, scalable messaging with a guaranteed at-least-once delivery. This new primitive builds on the foundation set by Deno KV, and is available today in the Deno JavaScript runtime and Deno Deploy.

307
1
308
1
309
1
310
1

This is a follow up to my previous article on how to get more TypeScript benefits in your JavaScript. This goes into how to add types using JSDoc or TypeScript declaration files.

311
2
312
1
313
1

Finally, i found the official documentation of Javascript

314
1
315
1
Issues with Mastodon TSL API (lemmy.blahaj.zone)

async MediaUpload(photos : any[]) { const client = await this.Login() const full_photo_urls : string[] = photos.map((item) => item.full) let image_ids : string[] = []; full_photo_urls.forEach(async (image_url) => { const image_blob = await fetch(image_url).then(res => res.blob()) try { console.log("images are about to be posted!"); const image_res = await client.postMediaAttachment({file: image_blob}) console.log("Images were posted here"); console.log(image_res); } catch (error) { console.error(error); } }) return image_ids;

Runs Error block which results in this

{ failed: true, json: { id: '111037763715692057', type: 'image', url: 'https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/original/c46fd6ce6b892c66.jpeg', preview_url: 'https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/small/c46fd6ce6b892c66.jpeg', remote_url: null, preview_remote_url: null, text_url: null, meta: { original: [Object], small: [Object] }, description: null, blurhash: 'UEHo8yIm%gV?9Exv%fM{?u~qM_D%xvITM{xa' }, path: 'media', response: Response { [Symbol(realm)]: null, [Symbol(state)]: { aborted: false, rangeRequested: false, timingAllowPassed: true, requestIncludesCredentials: true, type: 'default', status: 200, timingInfo: [Object], cacheState: '', statusText: 'OK', headersList: [HeadersList], urlList: [Array], body: [Object] }, [Symbol(headers)]: HeadersList { cookies: null, [Symbol(headers map)]: [Map], [Symbol(headers map sorted)]: null } }, status: 200, rateLimit: 30 }

I am really confused given it gives me a status code 200 which means OK, but still says it failed??? I also used my debugging to understand this is the line where the error occurs

const image_res = await client.postMediaAttachment({file: image_blob})

also ignore the fact imageres is unused, I removed the code after it for testing since to ensure nothing else was causing the error

316
1
317
1
318
1
319
1

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/sky/Documents/hourlypets/node_modules/tsl-mastodon-api/lib/index.js from /home/sky/Documents/hourlypets/src/mastodon.ts not supported. Instead change the require of index.js in /home/sky/Documents/hourlypets/src/mastodon.ts to a dynamic import() which is available in all CommonJS modules. at require.extensions. [as .js] (/usr/lib/node_modules/ts-node/dist/index.js:851:20) at Object. (/home/sky/Documents/hourlypets/src/mastodon.ts:36:31) at m._compile (/usr/lib/node_modules/ts-node/dist/index.js:857:29) at require.extensions. [as .ts] (/usr/lib/node_modules/ts-node/dist/index.js:859:16) at Object. (/home/sky/Documents/hourlypets/src/bot.ts:13:20) at m._compile (/usr/lib/node_modules/ts-node/dist/index.js:857:29) at require.extensions. [as .ts] (/usr/lib/node_modules/ts-node/dist/index.js:859:16) at phase4 (/usr/lib/node_modules/ts-node/dist/bin.js:466:20) at bootstrap (/usr/lib/node_modules/ts-node/dist/bin.js:54:12) at main (/usr/lib/node_modules/ts-node/dist/bin.js:33:12) at Object. (/usr/lib/node_modules/ts-node/dist/bin.js:579:5) { code: 'ERR_REQUIRE_ESM' } I am importing the lib like this

import * as Mastodon from 'tsl-mastodon-api';

320
1
submitted 3 years ago* (last edited 3 years ago) by pastelmind@programming.dev to c/javascript@programming.dev

The Rome project appears to be dead. Several of its maintainers have stepped up to create a fork named Biome.

See also: tweet by Jonny Burger

321
1
322
1
323
1
324
1
325
1

Hello Everyone,

The issue: I have created a page that loads two other pages into div's at the press of a button, and then removes them on another press

Both these pages contain JavaScript. On one of the pages, the JavaScript fires when the page is loaded to fill out values pulled from a database.

The pages are loaded using a simple Ajax call, that puts the contents in the div.

The problem: obviously loading pages this way means I can't use 'document.load' to fire the JavaScript. I'm also finding that none of the scripts are loaded either.

I have a solution that can load the JavaScript after completion of the document.load, but for some reason it's not detecting the global variables with the initial Json data in it.

Both pages work individually.

The question:

  1. How do I get this to work?
  2. Is there a better (preferably non-iframe) way of doing this?
  3. Why, when the JavaScript is loaded manually, is it seeing the global Json values as 'not yet defined'?

Happy to offer any other information needed.

Thanks in advance

view more: ‹ prev next ›

JavaScript

2786 readers
1 users here now

founded 3 years ago
MODERATORS