Skip to content

How to implement a fetch in Rust etc. correctly (for Tauri) #1039

@hippietrail

Description

@hippietrail

Question

I'm playing with Tauri and YouTube.js at the same time for an app idea.

Tauri is like Eclipse except it doesn't come with NodeJS so backend code will be in Rust.
Because it runs a webview locally it can't use the built-in fetch due to cross-site security.

I wrote a fetch() bridge in TypeScript and Rust that gets passed to InnerTube.create() and is implemented in Rust reqwest in the backend.

This works fine for fetching comments on a video by following the example code.

But I can't get it to work for fetching the transcript. The call to getInfo always fails with:

[Log] Received response: (main.ts, line 111)
Object

ok: false

status: 400

statusText: undefined

text: "{↵  \"error\": {↵    \"code\": 400,↵    \"message\": \"Precondition check failed.\",↵    \"errors\": [↵      {↵        \"message\": \"Precondition chec…"

Object Prototype

If anyone has done similar in C or another systems language that would be just as useful. I'm not sure if I'm losing something to do with HTTP headers or body.context, or maybe I've just done something totally wrong that I can't see.

Other details

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions