Javascript 如何在fetchin react native中获取文本响应的第二行
这里我只想在Javascript 如何在fetchin react native中获取文本响应的第二行,javascript,react-native,fetch,Javascript,React Native,Fetch,这里我只想在toast消息中显示第二行,因此如何获取第二行。我没有找到任何解决办法,所以请帮助我 以下是我的API调用代码: fetch(`${API_URL}api/${id}`, { method: 'get', }) .then((response) => { responseValue = response.status; // this is variable return response.text();
toast
消息中显示第二行,因此如何获取第二行。我没有找到任何解决办法,所以请帮助我
以下是我的API调用代码:
fetch(`${API_URL}api/${id}`, {
method: 'get',
})
.then((response) => {
responseValue = response.status; // this is variable
return response.text();
})
.then((result) => {
if (responseValue === 500) {
console.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^');
console.log(result);
}
})
.catch((err) => {
console.log(err);
});
听说有错误
Exception at /api/5fbf49d35d7473bf278149bc
Folio data not found
Request Method: GET
Request URL: https://example.com/api/barcode/bills/5fbf49d35d7473bf278149bc
Django Version: 3.0.5
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.6.9
Exception Type: Exception at /api/
Exception Value: Folio data not found
Request information:
USER: AnonymousUser
GET: No GET data
POST: No POST data
FILES: No FILES data
尝试使用
split
,如下所示
console.log(error.split('\n')[1]);
您需要提供一些代码片段,说明如何调用此API OK我将更新我的问题OK问题updated@miteshkalal你能给我们提供结果文本吗?告诉我们你尝试了什么(以适当的形式,意思是在必要时将fetch响应作为静态数据包含),而不是仅仅说你尝试了东西。