Код: Выделить всё
import React, { useEffect, useState } from "react";
import { View, Text, StyleSheet } from "react-native";
import { WebView } from "react-native-webview";
import { IPV4_ADDRESS } from "../views/SiteHome";
export const NodeContent = ({ route }) => {
const { id, ticket } = route.params;
const [pdfUrl, setPdfUrl] = useState("");
const fetchContentNode = async (id, ticket) => {
const myheaders = {
method: "GET",
headers: {
Authorization: "Basic " + ticket,
},
};
const response = await fetch(
`http://${IPV4_ADDRESS}:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/${id}/content`,
myheaders
);
const pdfUrl = response.url;
console.log(pdfUrl)
return pdfUrl;
};
useEffect(() => {
const getPdfUrl = async () => {
const url = await fetchContentNode(id, ticket);
setPdfUrl(url);
};
getPdfUrl();
}, [id, ticket]);
return (
{pdfUrl ? (
) : (
Loading PDF...
)}
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
});
Извините за мой английский
Подробнее здесь: https://stackoverflow.com/questions/776 ... act-native