How to get actual image from image path in http response? - reactjs

I am making a http request which responds back with an image path like so
{
poster-path: /heb234gdb.jpg
}
I tried adding this path to the end of the same http request, removing everything else and using this path at the end of the main api url, simply using this path and a lot more but I can't get the image to show. What is the way to do this?
P.S.: I did not give the api urls purposely but if any more info is needed please comment

First of all , Edit your question!.
You can have the description in Code Snippet ,its annoying.

Like #jessy said I had to read the documentation and I found a completely separate API's link at the end of which I had to add the path to get the image.

Related

How do get the result from REST website that returns only text?

I'm trying to use a REST web service from Geonames.org. When I try to manually put in the url with the parameters, it would only return the Country Code. I've tried to search for ways to implement it, but most of what I've seen return JSON text with multiple keys and data. I feel like the answer should be pretty simple, but I'm unsure.
I'm trying to use this for a React project I'm working on.
Here is an example of what the url returns
Just looked into the docs of that API, and it says if you want to receive JSON responses simply add JSON keyword to the endpoint. Like here for given endpoint you have:
http://api.geonames.org/countryCodeJSON?formatted=true&lat=47.03&lng=10.2&username=demo
so just change countryCode to countryCodeJSON.
Source: http://www.geonames.org/export/JSON-webservices.html

Error by reading Header values from Logic App HTTP Request

In a if condition I tried to get a header value (secret key) I'am sending to the Logic App.
The following code is used to get the secret from the header (In this example i have parsed it before)
#body('Parse_Header_from_HTTP_Request')?['headers']?['Secret']
I have also tried the solution from this answered question:
Azure Logic Apps : Get HTTP Request Header Key Value into Conditional Check
The variable is null if I check it on the Run History.
According to your description, I do not know how you parse your header before.
Here I use Parse Json to achieve, you could refer to the screenshot as below:
After setting body('Parse_Json')?['name'] to get name value, the output is as below:
As you have said, you have parsed the header after http request. So, after parsing headers, the value is from parse_json, while you refer to the link you provided which value is from http request header.
Hope it helps you.

AngularJS $http service has CORS issue. But it should be working for JSONP, right? [duplicate]

I'm trying to load an external page using JSONP, but the page is an HTML page, I just want to grab the contents of it using ajax.
EDIT: The reason why I'm doing this is because I want to pass all the user information ex: headers, ip, agent, when loading the page rather than my servers.
Is this doable? Right now, I can get the page, but jsonp attempts to parse the json, returning an error: Uncaught SyntaxError: Unexpected token <
Sample code:
$.post('http://example.com',function(data){
$('.results').html(data);
},'jsonp');
I've set up a jsfiddle for people to test with:
http://jsfiddle.net/8A63A/1/
http://en.wikipedia.org/wiki/JSONP#Script_element_injection
Making a JSONP call (in other words, to employ this usage pattern),
requires a script element. Therefore, for each new JSONP request, the
browser must add (or reuse) a new element—in other words,
inject the element—into the HTML DOM, with the desired value for the
"src" attribute. This element is then evaluated, the src URL is
retrieved, and the response JSON is evaluated.
Now look at your error:
Uncaught SyntaxError: Unexpected token <
< is the first character of any html tag, probably this is the start of <DOCTYPE, in this case, which is, of course, invalid JavaScript.
And NO, you can't use JSONP for fetching html data.
I have done what you want but in my case I have control of the server side code that returns the HTML.
So, what I did was wrapped the HTML code in one of the Json properties of the returned object and used it at client side, something like:
callback({"page": "<html>...</html>"})
The Syntax error you are facing it's because the library you're using expects json but the response is HTML, just that.
I've got three words for you: Same Origin Policy
Unless the remote URL actually supports proper JSONP requests, you won't be able to do what you're trying to. And that's a good thing.
Edit: You could of course try to proxy the request through your server …
If you really just want to employ the client to snag an HTML file, I suggest using flyJSONP - which uses YQL.. or use jankyPOST which uses some sweet techniques:
jankyPOST creates a hidden iframe and stuffs it with a form (iframe[0].contentWindow.document.body.form.name).
Then it uses HTML5 (watch legacy browsers!) webMessaging API to post to the other iframe and sets iframe's form elements' vals to what u specified.
Submits form to remote server...done.
Or you could just use PHP curl, parse it, echo it, so on.
IDK if what exactly ur using it for but I hope this helps.
ALSO...
I'm pretty sure you can JSONP anything that is an output from server code. I did this with ClientLogin by just JSONPing their keyGen page and successfully consoleLogged the text even though it was b/w tags. I had some other errors on that but point is that I scraped that output.
Currently, I'm trying to do what you are so I'll post back if successful.
I don't think this is possible. JSONP requires that the response is rendered properly.
If you want another solution, what about loading the url in an iframe and trying to talk through the iframe. I'm not 100% positive it will work, but it's worth a shot.
First, call the AJAX URL manually and see of the resulting HTML makes sense.
Second, you need to close your DIV in your fiddle example.

Why isn't get_serving_url() cropping working correctly?

According to the App Engine docs there's a method get_serving_url which gives a URL to an image in the blobstore that can then be resized an cropped. So I can take a URL like:
http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z
add =w300-c:
http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z=w300-c
and it should turn into a 300x300 square image.
Except, at the time of writing this post, the image that is returned by the 2nd of the above URLs is horribly malformed.
Is this a bug? Or am I doing something wrong?
It's a typo in your url. The documentation says you need to append =sXX-c not =wXX-c.
In your case you need to use the url http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z=s300-c

Injecting image content into webkit load

Inside my WebKitGTK+ widget, I want to transparently replace some of the images of an HTML page with different image data I hold in memory.
According to the documentation at http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView-resource-request-starting, I've hooked into this signal, which allows the request URI to be changed, but what I really want is to leave it unchanged but generate my own response.
I've tried filling out the WebKitWebResource parameter, and filling out the SoupMessage response from the WebKitNetworkRequest to no avail. Anyone know how to do this?
figured out one way to do it: replacing the request URL with "data:image/jpeg;base64,[inline data]".
Will do for me.

Resources