Last curly brace or last bracket is missing in fetch response
See original GitHub issueDescription
Sometimes(but often) last curly brace or last bracket is missing from fetch response. It is correct in Postman but not in React Native.
React Native version:
0.64
Steps To Reproduce
- Call fetch method in React native Component until you get an error.
Expected Results
Result should be same as postman response but sometimes it’s incorrect. Last curly brace or last bracket is missing in fetch response.
Snack, code example
async changePasswordFromApi(password, newPassword) { var param = { password: password, newpassword: newPassword }; var token = await getToken();
return fetch(address.changePassword(), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
body: JSON.stringify(param)
})
.then(response => response.text())
.then((data) => {
//Sometimes `data` is missing last curly brace or last bracket.
})
.catch((error) => {
console.log("------------- Change Password Error" + error)
return null;
});
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Can anyone spot the missing curly bracket - Stack Overflow
Notice: In this code block, going straight down from function addCTHValue() you do not reach a curly brace. Where does the function end?...
Read more >keep getting told my curly brackets are missing? - Codecademy
“Oops, try again. Check that your curly braces are correct. The one on line 2 might be missing a curly brace.”
Read more >apex - Pulling values from inner curly brackets
I am trying to pull the values from a JSON response and have managed to ... the one I need which is nested...
Read more >SyntaxError: missing } after function body - JavaScript | MDN
The JavaScript exception "missing } after function body" occurs when there is a ... Check if any closing curly brackets or parenthesis are...
Read more >SyntaxError: Unexpected token in JavaScript | bobbyhadz
There is an extra curly brace on the third line, which causes the error. unexpected token curly brace.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This doesn’t look like a React Native issue - the framework depends on other libraries for HTTP functionality.
react-native info
in a console.