question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Last curly brace or last bracket is missing in fetch response

See original GitHub issue

Description

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

  1. 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:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rectified95commented, Jul 13, 2021

This doesn’t look like a React Native issue - the framework depends on other libraries for HTTP functionality.

0reactions
github-actions[bot]commented, Jul 13, 2021
:warning: Missing Environment Information
:information_source: Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found