Question: I'm trying to build a simple web app using the MERN stack while following a course.

My backend runs on port 5000 while react runs on port 3000. When I want to make a request with the backend API, it sends it to port 3000 instead of 5000. I keep on getting this error message:

> 
> xhr.js:178 POST http://localhost:3000/api/users 400 (Bad Request)
> 
> 
> 

I included `"proxy" : "http://localhost:5000"` in my package.json. I tried replacing 'localhost' with 127.0.0.1. I tried deleting and reinstalling the package-lock.json and node\_modules folders. I tried removing the proxy and using the entire url. I tried installing http proxy middleware. I tried enabling CORS on the backend too.

Either I'm cursed or doing everything wrong.

I'm using axios for handling the requests, here's the code.

```
const config = {
     headers: {
         'Content-type': "application-json"
     }
}

const body = JSON.stringify(newUser)
const res = await axios.post('/api/users', body, config)
console.log(res.data)

```

Answer: 
As pickle is not secure you can use `json` format

```
dump/dumps: Serialize
load/loads: Deserialize

```

<https://docs.python.org/3/library/json.html>

Code:

```
>>> import json
>>> l = [1,2,3,4]
>>> with open("test.txt", "w") as fp:
...     json.dump(l, fp)
...
>>> with open("test.txt", "r") as fp:
...     b = json.load(fp)
...
>>> b
[1, 2, 3, 4]

```
If you are wanting to write a python list to a txt file and then read it back in as a list you need to do something like this.

Write it with some delimiter.

```
with open("myfile.txt", "w") as f:
    string1 = ",".join(map(str, LIST))
    f.write(string1)

```

And then read it in and split it on that same delimiter.

```

with open("myfile.txt", "r") as f:
    text = f.read()
    my_list = text.split(',')

```