«com.facebook.react.bridge.ReadableNativeMap не может быть преобразован в java.lang.string» при попытке получить информаJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 «com.facebook.react.bridge.ReadableNativeMap не может быть преобразован в java.lang.string» при попытке получить информа

Сообщение Anonymous »

Я пытаюсь получить информацию из json-файла Google Диска.
Однако я получаю сообщение об ошибке: «com.facebook.react.bridge.ReadableNativeMap невозможно привести к java.lang». .string», хотя я вижу, что результат кода кажется правильным, за 1 секунду до появления ошибки....
Вот мой код:

Код: Выделить всё

// Fetch user profiles and posts from Google Drive
const getUserProfilesFromGoogleDrive = async (accessToken) => {
try {
const deviceID = await AsyncStorage.getItem('deviceID');
let last4Chars = deviceID ? deviceID.slice(-4) : null;
if (!last4Chars) {
console.error('No deviceID found');
return;
}

const fileResponse = await axios.get('https://www.googleapis.com/drive/v3/files', {
headers: { Authorization: `Bearer ${accessToken}` },
params: { q: "name='user-profiles.json'", fields: 'files(id,name)' }
});

const fileId = fileResponse.data.files[0]?.id;
if (!fileId) {
console.error('File not found');
return;
}

const downloadResponse = await axios.get(`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`, {
headers: { Authorization: `Bearer ${accessToken}` },
responseType: 'arraybuffer'
});

const text = Buffer.from(downloadResponse.data).toString('utf-8');
let profiles = JSON.parse(text);

const matchedProfiles = profiles.filter(profile =>
profile.followerDetails?.includes(last4Chars)
);

if (!matchedProfiles.length) {
console.log('No profiles found');
return;
}

let allUserMemes = [];
for (const profile of matchedProfiles) {
profile.posts?.forEach(post => {
console.log(`Downloading post: ${post.fileName}`);
allUserMemes.push(post);
// Download the post's image (file specific to the post)
downloadPostFromDrive(post.fileName, post.driveId, accessToken);
});
}

setUserPosts(allUserMemes);
} catch (error) {
console.error('Error fetching profiles:', error);
}
};
Я пытался найти любого другого человека, у которого была такая же проблема, но ничего не помогло.
Поэтому, пожалуйста, взгляните на мой код и скажите мне, что не так, я был бы очень признателен, так как потратил на это целый день

Подробнее здесь: https://stackoverflow.com/questions/793 ... ang-string
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»