Home > Back-end >  How do I skip extracting a value that is None in Python requests
How do I skip extracting a value that is None in Python requests

Time:09-28

I am currently working with Python requests to get data from an API. I'm trying to have a nested request within the request depending on the value received from one of the responses. So basically, I make a request and one of the fields returned is uid. I want again to pop that value into another request and that value makes part of the url. eg. f"https://registry.nbnatlas.org/ws/dataResource/{uid}". The only issue is that some responses have a null value for the uid field and this throws an error when making the nested request.

What I am trying to do is to skip the second request if the uid field is null

CodePudding user response:

You can just add if uid is not None: before the second request

  • Related