MCPcopy Create free account
hub / github.com/apify/impit / bytes

Method bytes

impit-node/src/response.rs:231–242  ·  view source on GitHub ↗
(&'env self, env: &'env Env, this: This<'env>)

Source from the content-addressed store, hash-verified

229 /// as the response body can only be consumed once. Subsequent calls will result in an error.
230 #[napi(ts_return_type = "Promise<Uint8Array>")]
231 pub fn bytes(&'env self, env: &'env Env, this: This<'env>) -> Result<Object<'env>> {
232 let array_buffer_promise = self.array_buffer(env, this)?;
233 let then: Function<'_, Function<Object, Unknown>, Object> =
234 array_buffer_promise.get_named_property("then")?;
235
236 let cb = env
237 .get_global()?
238 .get_named_property::<Function<'_, String, Function<Object, Unknown>>>("eval")?
239 .call("(buf) => new Uint8Array(buf)".to_string())?;
240
241 then.apply(Some(&array_buffer_promise), cb)
242 }
243
244 /// Returns the response body as a string.
245 ///

Callers 6

textMethod · 0.80
#wrapResponseMethod · 0.80
basics.test.tsFile · 0.80
areadMethod · 0.80
readMethod · 0.80
from_asyncMethod · 0.80

Calls 1

array_bufferMethod · 0.80

Tested by

no test coverage detected